-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically switch app language based on device language. #6587
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found an issue, the code works correctly for language codes like "ja" and "ko", but doesn't work when there's a regional variant, such as "zh-CN".
@auroursa I believe adding a new dependency is not needed, as the app already depends on |
Thank you! I've switched to using expo-localization, and it works well with the regional language codes (except for Chinese). Maybe react-native-localization-settings still has value, as it allows users to switch languages through the system settings. |
Updated Chinese language code to follow IETF-BCP-47, and now all languages supported by the app are working correctly. |
It will break the browser’s automatic language switching behavior. Closing this PR until ready. |
Let’s introduce a package react-native-localization-settings to make the app’s language selectable in the device settings(Update: It’s not required, but I think it could improve user experience).
Based on
expo-localization
, the app language can automatically follow system language. For example, if the device language is set to Japanese, the app will automatically switch to Japanese (instead of English), similar to our web matches the browser language.To compatibility with Android and iOS language codes, the Chinese language code needs to be modified to follow the IETF-BCP-47 format. I’ve tested it on Android versions 7 to 14, and all app language are working fine.
It should work well on iOS, but I haven't had the opportunity to test it.
example.mp4