moko-resources
moko-resources copied to clipboard
Support for string-array
In Android I can use string-array in XML code like the following:
<string-array name="someArray">
<item>Item 1</item>
<item>Item 2</item>
</string-array>
Would it be possible to support it in this library?
i not sure that on iOS we have analog. need to research
I don't think that there is an equivalent for iOS, but it might be possible to implement the behavior in a different way. Maybe by doing something like adding the strings as someArray_1, someArray_2, etc. in the strings files and providing it as
actual val someArray: Array<StringResource> = arrayOf(StringResource(R.string.someArray_1), StringResource(R.string.someArray_2))
respectively
actual val someArray: Array<StringResource> = arrayOf(StringResource(resourceId = "someArray_1", bundle = bundle), StringResource(resourceId = "someArray_2", bundle = bundle))
instead of plain StringResource. One could then iterate over someArray to get all values. What do you think of that approach?
It would be great if you follow up adding support for string arrays to the lib. That would make the lib even more valuable for KMM projects.
Hello! Any updates on this? :)
EDIT:
@ln-12 As a workaround, I used something similar to what you suggested, I broke my array into separate strings with the same prefix, and then used the arrayOf, it might not be optimized, or flexible, but it works
val choicesArray = arrayOf(
getString(R.string.choices_option_1),
getString(R.string.choices_option_2)
)
So, I think for iOS it would work as a workaround, if the generator would take care of this boilerplate. For android, the default api can still be used