lunetics-org / LocaleBundle

Locale Bundle for symfony
MIT License
187 stars 76 forks source link

LocalBundle country code standard ??? #181

Open maity-kgz opened 8 years ago

maity-kgz commented 8 years ago

If I configure locales in Symfony CMF app/config/parameters.yml with "kg" country code which stands for Kyrgyzstan according to ISO 3166-1 alpha-2 standard than in LocaleBundle switcher i get Congo country which is totally wrong, but in admin panel SonataTranslationBundle shows correct flag of Kyrgyzstan.

I figured out that LocaleBundle uses "ky" code for Kyrgyzstan but according to ISO 3166-1 alpha-2 standard this code is for Cayman Islands. If I use "ky" locale in app/config/parametes.yml than LocaleBundles switcher shows correct Kyrgyzstan but in admin SonataTranslationBundle shows me Cayman Islands flag.

used default params for LocaleBundle:

>  lunetics_locale:

    strict_mode: true

    guessing_order:

        - router

        - cookie

        - browser

    allowed_locales: '%locales%'
hacfi commented 8 years ago

@maity-kgz This bundles uses symfony/intl which uses ISO 639-1. Not sure how to deal with this issue though.

dbu commented 8 years ago

there seem to be other issues with the data symfony/intl is using: https://github.com/symfony/symfony/issues/12583

no idea however if things could be customized/extended/overridden to work around this, or how the root cause could be solved, sorry.

jakzal commented 8 years ago

Symfony is merely a consumer of data provided by ICU. According to ICU, kg is a language code for Kongo, while ky is a language code for Kyrgyz. These are ISO-639-1 codes used by Symfony:

The "value" for each locale is either the two letter ISO 639-1 language code (e.g. fr), or the language code followed by an underscore (_), then the ISO 3166-1 alpha-2 country code (e.g. fr_FR for French/France).

@maity-kgz by using kg you're telling Symfony to use Kongo language. You should either use ky or ky_KG. It appears to be a valid locale for Kyrgyztan. Locale for Kayman Islands is en_KY.

maity-kgz commented 8 years ago

@jakzal all you said is valid for Symfony2 forms but not to this issue. Thing is that using ky_KG is not solve the issue. Because LocalBundle is not support that type of code.

jakzal commented 8 years ago

What do you mean it's not supported?

The following code returns Kyrgyz (Kyrgyzstan):

echo \Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleName('ky_KG');
jakzal commented 8 years ago

Just realised you were talking about LocaleBundle from this repository. I never used it and perhaps it needs fixing (maybe it confuses the country code with locale). I only explained there's nothing wrong with Symfony's components (as this issue was linked to the Symfony's issue).

dbu commented 8 years ago

thanks @jakzal

@maity-kgz if you have time to dig though this with the pointers jakub gave, i am glad to help reviewing a pull request to fix this. if we do any duplication in here where we could use the symfony intl component, we should go for symfony intl...