I am trying to build an in-app language switcher for the app I am working on, but I have tried almost everything method available on Stackoverflow. I also tried Official guide from here https://developer.android.com/guide/topics/resources/app-languages#api-implementation
Nothing seems to work. Here is the code on GitHub https://github.com/bauripalash/Pankti-Android
Here's the settings screen where I am changing the language
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()
}
And here's main activity
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()
                }
            }
        }
    }
}
Recreating the activity, doesn't work either.
I have tried almost every method i could find on Stackoverflow and elsewhere.
Android context.getResources.updateConfiguration() deprecated
How to trigger recomposition after updateConfiguration?
How to force jetpack compose to recompose?
Android Language change using JetPack Compose
I know this type of question is being asked a lot here. But can someone help me here.
 
    



