Skip to content
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

UI not recomposed when locale changes #30

Open
dalewking opened this issue Nov 27, 2023 · 2 comments
Open

UI not recomposed when locale changes #30

dalewking opened this issue Nov 27, 2023 · 2 comments

Comments

@dalewking
Copy link

If you are in the app, go to settings and change the locale to another one that is supported the UI is not automatically recomposed so none of the strings will change to the new locale

@dalewking
Copy link
Author

see this for similar issue with stringResource: https://issuetracker.google.com/issues/167352819

@dalewking
Copy link
Author

Not sure this is something that can currently be fixed with lyricist as it seems compose does not expose a Locale State. Here is how I am looking to work around it on Android:

class MainActivity : ComponentActivity() {
    private val locale = mutableStateOf(Locale.current)
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        setContent {
            App(locale.value)
        }
    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        super.onConfigurationChanged(newConfig)
        locale.value = Locale.current
    }
}
fun App(locale: Locale) {
    ProvideStrings(rememberStrings(currentLanguageTag = locale.toLanguageTag())) {
        Navigator(mainScreen)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant