ReactNativeLocalization
ReactNativeLocalization copied to clipboard
Wrong language set on iOS 11 Beta
Hello!
I have two languages in my app en
and de
:
import LocalizedStrings from 'react-native-localization'
import en from './langs/en'
import de from './langs/de'
const strings = new LocalizedStrings({
en,
de,
})
export default strings
Everything works fine, but recently I discovered that my friend and his girlfriend do have iOS 11 Beta with german language set in system settings and the app in both cases is localized in english (settings screenshot attached)
Is it a bug or am I doing something wrong?
Hi, I've not yet installed the beta so I don't know if Apple as (again) changed the way current language is reported...
I'll check it asap..
Thank you, I appreciate that!
Hi, I am having the same issue, I have multiple languages in the project like en, es, de, fr, fi, it, ja, ko, nl, pt etc. In other ios version language is correctly selected. But in ios 11, only english is showing. I used Strings.getInterfaceLanguage(); method to find out current language it is giving result, "en-US" independent of selected language. It would be extremely helpful to get the help. Thanks and regards
Hi, I may have found a temporary fix. It works for me. Install "react-native-device-info" module. and get language like const currentLanguage = DeviceInfo.getDeviceLocale(); after initializing LocalizedStrings add the following line string.setLanguage(currentLanguage); This line will change the language of App. Please check and confirm. Thanks and regards
Hi, I've finally been able to install iOS11 GM, and I've made a test.
I set the interface to ITALIAN - SWISS and strings.getInterfaceLanguage() returns "it-CH" like it should, showing the it strings (I've got en-US, en, it)...
Am I missing something? Thanks
I am developing an application that uses English and German as languages and I experience the same issue on iOS 11: Even though the iPhone language is set to German, the application itself is using English as language.
It worked fine on iOS 10 and still works on Android.
what happens if you print the results of strings.getInterfaceLanguage() ?
While the selection of the region seems to work, the language is always recognized as English. I get: en-DE for German with region Germany en-CA for French with region Canada en-CH for Italian with region Switzerland
This happens on the device as well as on the simulator.
This is the method called: https://developer.apple.com/documentation/foundation/nslocale/1409990-currentlocale
as stated it should return the current locale (even if it doesn't change when it's changed when the app is running...)
Here they say that the code should not be used to retrieve language, but I changed the method because iOS 10 removed the original call...
The orignal code used
[[NSLocale preferredLanguages] objectAtIndex:0];
but didn't hold any information about the regional settings... I'll experiment with some hybrid approach...
I think this happens if you haven't configured all the supported localizations in the Xcode project: https://stackoverflow.com/questions/46205763/nsdateformatter-and-current-language-in-ios11
@jsslai that seems exactly our case!
@fliPmitKlammern could you add support to the other languages in your PLIST and check if it works?
@stefalda Adding the missing languages fixed the issue in our project.
I think the iOS 11 way is better but I couldn't find any info about the change in Apple's documentation.
That did the trick for me, thank you very much!
I followed the 3 first steps http://www.ibabbleon.com/iphone_app_localization.html and it works
I was having the same issue. I can confirm that if you list in the info.list file the languages it will work on IOS 11
<key>CFBundleLocalizations</key>
<array>
<string>English</string>
<string>French</string>
</array>
I am facing the same issue. The issue is with iOS 11 changes in Locationlization. So, prior to iOS 11, [NSLocale currentLocale] would return the language set in Language settings, But in ios 11 [NSLocale currentLocale] would return only the languages supported in App base localization. So you need to enable all those languages in app settings first. Refer to this link: https://stackoverflow.com/questions/46205763/nsdateformatter-and-current-language-in-ios11