ptsiogas
03/13/2023, 4:12 PMfun setLocale(locale: String) {
StringDesc.localeType = StringDesc.LocaleType.Custom (locale)
}
alex009
03/13/2023, 6:53 PMStringDesc.localize
you will read system languageVidmantas Kerbelis
03/14/2023, 7:04 AMlocale
you are passing and do you have this exact resource directory?
You have to pass the exact locale as the resource directory is named under resources/MR/*
.
So if you have a directory called fr
, you cannot pass fr-FR
as a locale
. You must pass fr
, or add some additional logic to resolve thisalex009
03/14/2023, 8:37 AM<locale>.jproj
- https://github.com/icerockdev/moko-resources/blob/df157ee999b787bf0d3628ab33747ce5[…]/appleMain/kotlin/dev/icerock/moko/resources/desc/StringDesc.kt
for android we use system logic with Context locale change - https://github.com/icerockdev/moko-resources/blob/df157ee999b787bf0d3628ab33747ce5[…]src/androidMain/kotlin/dev/icerock/moko/resources/desc/Utils.kt
for jvm we pass locale to class loader api - https://github.com/icerockdev/moko-resources/blob/df157ee999b787bf0d3628ab33747ce5[…]src/jvmMain/kotlin/dev/icerock/moko/resources/StringResource.kt
for js we search localization file with <locale> name - https://github.com/icerockdev/moko-resources/blob/df157ee999b787bf0d3628ab33747ce5[…]/kotlin/dev/icerock/moko/resources/provider/JsStringProvider.ktptsiogas
03/14/2023, 8:44 AMiosBaseLocalizationRegion = "el"
(not worked) and leave it blank (also not worked)
The setup that seems to work (I must confirm it 100%) is this:
1. The base folder contains the english strings
2. I have also created a second folder named “el” for the greek strings.
3. iosBaseLocalizationRegion = "en"
4. In order to change locale I call the function:
fun setLocale(locale: String) {
StringDesc.localeType = StringDesc.LocaleType.Custom (locale)
}
with the appropriate locale (“en” or “el”).ptsiogas
03/14/2023, 8:46 AMLocalizable.strings
file seems fine but I suspect that there is a typo somewhere in the strings.xml file.alex009
03/14/2023, 11:11 AMios-app Info.plist
blockalex009
03/14/2023, 11:12 AMptsiogas
03/14/2023, 11:38 AMLocalizable.strings
file for english was invalid and the iOS did a fallback and returned the key.
In order to confirm that the content of the Localizable.strings
was invalid I took it’s strings and placed them into xcode’s Localizable strings. Then I took a compile error.
This time the issue was the text above:
"my_key" = "Click \\"Continue\\" to choose how you want to receive the new equipment.\\"";
and the KMM string was this:
<string name="my_key">Click \"Continue\" to choose how you want to receive the new equipment.\"</string>
Apparently there was no compile issue and the android code worked fine. If I may suggest, there should be an extra check in order to determine that the produced Localizable.strings
file inside any .lproj folder is valid.alex009
03/14/2023, 11:42 AMptsiogas
03/14/2023, 11:44 AMptsiogas
03/14/2023, 11:47 AMplutil -lint Localizable.strings
ptsiogas
03/14/2023, 11:47 AMBekzod
04/18/2024, 10:44 AM@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
fun setLocale(locale: String) {
StringDesc.localeType = StringDesc.LocaleType.Custom(locale)
preferenceManager?.setLocale(locale)
}
I'm new to iOS development, need some instructions. Thanks in advance!alex009
04/18/2024, 2:22 PMBekzod
04/22/2024, 12:50 PM