countries / country_select

Gemification of rails's country_select
https://country-select-demo.onrender.com
MIT License
704 stars 198 forks source link

Sensitiveness #206

Open frankapimenta opened 2 years ago

frankapimenta commented 2 years ago

Some countries have different cultural regions (Spain (Basc country, Catalonia), Belgium (fr, nl), Switzerland (it, fr, de as example). Is there a way to add this specification to the gem?

I see that for Switzerland

@country_data_or_code[:translations]

has

{ "ch-fr"=>nil, "ch-de"=>nil", "ch-it"=>nil }

Would be nice to have this as culture specification of the country. For example:

@country_data_or_code[:locales] => { "ch-fr" => 🇨🇭🇫🇷, "ch-de" => 🇨🇭🇩🇪, "ch-it" => 🇨🇭🇮🇹 }

and have locales as a options of the values of the select options (dropdownlist).

pmor commented 1 year ago

All the data comes from the countries gem, and that gem does have a lot of translations, but it doesn't specifically deal with regional locales.

The base country data for Switzerland is https://github.com/countries/countries/blob/832ac5afd68ff467758f722fc6f330a8831b75ee/lib/countries/data/countries/CH.yaml and it includes the list of languages, but not the actual locale identifiers.

I'll add a ticket to countries to add the locales, it makes sense to have this data.

I don't know where those locales you mention are coming from, because the proper identifiers should be fr-CH, de-CH and it-CH. The format is <language>-<countryCode>.

If you configure I18n.available_locales or directly for the countries gem (see here) and add :fr, :de, :it then the translation data for these languages will be loaded.