Closed auroursa closed 11 hours ago
@auroursa I believe adding a new dependency is not needed, as the app already depends on expo-localization
. You can use the Localization.getLocales()
method to get the current language: https://docs.expo.dev/versions/latest/sdk/localization/#localizationgetlocales.
@auroursa I believe adding a new dependency is not needed, as the app already depends on
expo-localization
. You can use theLocalization.getLocales()
method to get the current language: https://docs.expo.dev/versions/latest/sdk/localization/#localizationgetlocales.
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.
https://github.com/user-attachments/assets/dadecbb2-ed16-4c00-af1e-b777f31ce08e