Hi there, I also tried to change locale from app. ...
# moko
b
Hi there, I also tried to change locale from app. if I set localeType in start up it is working
import SwiftUI
import shared
@main
struct iOSApp: App {
init() {
//here
KoinHelperKt.doInitKoin()
}
var body: some Scene {
WindowGroup {
ContentView()
.preferredColorScheme(.light)
}
}
}
but later when I tried to call it in runtime, it did not work. re-opened app still no changes.
fun setLocale(locale: String) {
StringDesc.localeType = StringDesc.LocaleType.Custom(locale)
preferenceManager?.setLocale(locale)
}
If language changed from settings it works. I'm new to iOS development, need some instructions. Thanks in advance!
in pure iOS, it is recommended to use environment
struct ContentView: View {
@Environment(\.locale) var locale
var body: some View {
// Use the locale to customize your views
Text("Hello, World!")
.environment(\.locale, locale)
}
}
I wonder if I need to use this too, but not sure how to combine both