ReactNativeLocalization icon indicating copy to clipboard operation
ReactNativeLocalization copied to clipboard

Country and variant doesn't work (for example, "zh-Hans")

Open tianxind opened this issue 8 years ago • 3 comments

The country specific variant doesn't work for me. For example, when I try to differentiate between Chinese Simplified and Chinese traditional on iOS, this library fails to pick the correct strings from "zh-Hans" and "zh-Hant"

I am using RN 0.42.3

tianxind avatar Apr 25 '17 05:04 tianxind

I guess it depends from the iOS version... what version are you targeting? Because there've been some changes in the way the language is coded

stefalda avatar Jun 08 '17 21:06 stefalda

zh-Hant return [[NSLocale preferredLanguages] objectAtIndex:0]will always return the right language code.
on iOS 10 use currentLocale.languageCode miss Hant. maybe use [[NSLocale currentLocale] localeIdentifier]

peixin avatar Jul 20 '17 07:07 peixin

I am running RN 50 on iOS. Just make sure that you put quotes for country and local variant, like so:

en:{ } 'fr-FR': { } 'fr-CA': { }

Further reference: https://developer.apple.com/library/content/documentation/MacOSX/Conceptual/BPInternational/LanguageandLocaleIDs/LanguageandLocaleIDs.html

unmec avatar Nov 14 '17 04:11 unmec