https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
d

Daniele B

03/10/2021, 9:15 PM
is there a way to define localized strings in an XML file in the CommonMain
resources
folder, and access the strings (just within the CommonMain, as it’s for a shared KMPViewModel) similarly to how it happens in Android?
m

Mustafa Ozhan

03/10/2021, 9:37 PM
did you try moko resources? https://github.com/icerockdev/moko-resources It is a great library and supports localisation
1
d

darkmoon_uk

03/10/2021, 9:50 PM
+1 Moko resources, we are using this successfully
d

Daniele B

03/10/2021, 10:03 PM
It seems Moko focuses on making CommonMain resources available to the Android and iOS platform specific code, by merging them into the platform-specific localization systems. I am just interested in using resources in CommonMain. I was wondering if KMP had by default for CommonMain a similar
res
mechanism of the Android framework. But I guess I am asking too much.
d

darkmoon_uk

03/10/2021, 11:31 PM
We achieved this in CommonMain by doing some platform component injection into the common space during App Startup. ...never the prettiest approach, but it works.
2 Views