bluesky-social / social-app

The Bluesky Social application for Web, iOS, and Android
https://bsky.app
MIT License
11.76k stars 1.5k forks source link

Automatically switch app language based on device language. #6587

Closed auroursa closed 11 hours ago

auroursa commented 23 hours ago

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

fobos531 commented 17 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 commented 16 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.

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.

auroursa commented 11 hours ago

Updated Chinese language code to follow IETF-BCP-47, and now all languages supported by the app are working correctly.

auroursa commented 11 hours ago

It will break the browser’s automatic language switching behavior. Closing this PR until ready.