Кажется, ничего не работает. Вот код на GitHub https://github.com/bauripalash/Pankti-Android
Вот экран настроек, где я меняю язык
Код: Выделить всё
fun Context.findActivity() : Activity? = when(this){
is Activity -> this
is ContextWrapper -> baseContext.findActivity()
else -> null
}
fun changeLanguage( context: Context , language: String ){
context.findActivity()?.runOnUiThread {
val appLocale = LocaleListCompat.forLanguageTags(language)
AppCompatDelegate.setApplicationLocales(appLocale)
//context.findActivity()?.recreate()
}
//context.findActivity()?.recreate()
}
А вот и основное действие
Код: Выделить всё
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
AppCompatDelegate.setApplicationLocales(LocaleListCompat.forLanguageTags("bn"))
AppCompatDelegate.getApplicationLocales()[0]?.let { Log.i("MainView" , it.displayLanguage) }
setContent {
PanktiMobTheme {
// A surface container using the 'background' color from the theme
Surface(
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background
) {
MainView()
}
}
}
}
}
Я попробовал почти все методы, которые смог найти в Stackoverflow и других местах.
Android context.getResources.updateConfiguration() устарел
Как запустить рекомпозицию после updateConfiguration?
Как заставить Jetpack Compose перекомпоновать?
/>Изменение языка Android с помощью JetPack Compose
Я знаю, что здесь часто задают вопросы такого типа. Но может ли кто-нибудь мне помочь?
Подробнее здесь: https://stackoverflow.com/questions/744 ... ot-working
Мобильная версия