Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small improvements #37

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

small improvements #37

wants to merge 4 commits into from

Conversation

nickolaich
Copy link

@nickolaich nickolaich commented Dec 11, 2023

  • bumped version in readme
  • added elixir to .tool-versions for asdf
  • moved Helpers for app's namespace
  • added idea to .gitignore
  • Helpers.country_alpha3_by_alpha2/1

@nickolaich nickolaich changed the title bump version at readme small improvements Dec 11, 2023
Comment on lines +520 to +528
def country_alpha3_by_alpha2(alpha2) do
alpha2 = String.upcase(alpha2)

case Enum.find(@country_codes, &(get_alpha2(&1) == alpha2)) do
nil -> nil
info = %{} -> Map.get(info, :alpha3)
end
end

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this function?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flo0807 I had saved alpha2 for languages and thought it's useful to find country alpha3 version from the library to use later for rendering flags. However may be it's not a best place for it and is project related. Idk, it's a helper function.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flo0807 I had language code in 2 char formats and wanted quickly find what alpha3 representation is supported by Flagpack and call rendering if it's not nil. Idk, it could be app related code though I've added it to the helper.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to switch to alpha-2 codes for rendering flags in a future version of this package (see #35). How about adding a Flagpack.Helpers.get_country_codes function that returns the list of structs containing alpha-2, alpha-3, country_name and numeric information?

def get_country_codes, do: @country_codes

Then you can implement the above filtering in your application, and we do not have a function mainly cut to your application.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flo0807 it sounds reasonable. what do you mean by numeric information?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the Flag Index or the list of country_codes in the Helper module.

In addition to the name, alpha2 and alpha3, every flag also has a unique numeric code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants