Hello, How do you manage String resources in Kotli...
# multiplatform
i
Hello, How do you manage String resources in Kotlin Multiplatform Mobile(Android & iOS)? I found this post(https://chrynan.codes/string-resources-in-kotlin-multiplatform/), but I wonder what the best practice is.
m
This seems like a good way to go
e
I do a hybrid of the “access by common identifier” pattern
i have a
StringRef
enum in my common library and then a
Resources
interface that has a
fun getString(ref: StringRef): CharSequence
method
then the android impl of the enum looks like
actual enum class StringRef(@StringRes val resID: Int)
so instead of a method that does the mapping, it’s baked into the definition of the enum
a
i
@murdock @edenman @alex009 thank you. I applied a simple way at first. But I’m trying to understand the way of
moko-resources
.
a
Strange to see that moko resources hard way) I will rethink readme
i
@alex009 Oh, it didn’t mean that
moko-resources
is hard to use. I cloned your team’s repository and then I saw how to generate the resource in moko-resource project such as MRGenerator. I mean that I am trying to understand moko-resource project structure.
1749 Views