cordova-plugin-globalization icon indicating copy to clipboard operation
cordova-plugin-globalization copied to clipboard

iOS - getLocaleName return `en-FR` when the phone is actually in `fr-FR`

Open zabojad opened this issue 6 years ago • 3 comments

On iOS, getLocaleName return en-FR when the phone is actually in fr-FR.

Tested with cordova-plugin-globalization 1.11.0 "Globalization".

zabojad avatar Dec 05 '18 17:12 zabojad

I've found the cause of this issue. Since iOS 11, [NSLocale currentLocale] will return the actual system lang only if the app has listed its supported locales in its *-info.plist file under the key:

<key>CFBundleLocalizations</key>
    <array>
        <string>en</string>
        <string>fr</string>
        <string>nl</string>
        <string>it</string>
        <string>de</string>
    </array>

I think that should be written in the cordova-plugin-globalization README file as an iOS specificity...

zabojad avatar Dec 05 '18 21:12 zabojad

Awesome find! Could you please create a PR for this in the README?
Would be great if it would also include a link to some source about this on an Apple website.

janpio avatar Dec 05 '18 21:12 janpio

Ow this is why! Been wondering for a long time why my language was not as it should be... +1 for the README suggestion.

Works after adding the following to the section in config.xml:

    <custom-config-file parent="CFBundleLocalizations" platform="ios" target="*-Info.plist">
                <array>
                    <string>en</string>
                    <string>fr</string>
                </array>
            </custom-config-file>

Bramzor avatar Jan 19 '19 04:01 Bramzor

We are archiving this repository following Apache Cordova's Deprecation Policy. We will not continue to work on this repository. Therefore all issues and pull requests are being closed. Thanks for your contribution.

jcesarmobile avatar Jan 08 '23 23:01 jcesarmobile