LocaleBundle icon indicating copy to clipboard operation
LocaleBundle copied to clipboard

LocalBundle country code standard ???

Open maity-kgz opened this issue 9 years ago • 7 comments

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%'

maity-kgz avatar Feb 18 '16 04:02 maity-kgz

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

hacfi avatar Feb 18 '16 08:02 hacfi

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.

dbu avatar Feb 18 '16 17:02 dbu

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.

jakzal avatar Mar 07 '16 17:03 jakzal

@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.

maity-kgz avatar Mar 09 '16 03:03 maity-kgz

What do you mean it's not supported?

The following code returns Kyrgyz (Kyrgyzstan):

echo \Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleName('ky_KG');

jakzal avatar Mar 09 '16 07:03 jakzal

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).

jakzal avatar Mar 09 '16 07:03 jakzal

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...

dbu avatar Mar 25 '16 10:03 dbu