Hello, anybody knows if it's possible to get strin...
# multiplatform
e
Hello, anybody knows if it's possible to get string
Resources
by key? Edit: For example: I know the name of the key that I need and I need the string associated, something like:
getString("my_string")
instead
getString(<http://Res.string.my|Res.string.my>_string)
e
@Raphael TEYSSANDIER Sorry, I didn't explain it correctly. I mean that I know the name of the key that I need and I need the string associated, something like:
getString("my_string")
instead
getString(<http://Res.string.my|Res.string.my>_string)
r
Oh, then I don't have any idea, sorry
d
@Enol Simón Did you find a solution to this?
e
@Duane Malcolm I had to create an object that acts as a map like that:
Copy code
val stringsMap =
        mapOf(
            "app_name" to Res.string.app_name,
        )
`
Copy code
fun getStringByKey(name: String): String? =
            val res = MapResources.stringsMap[name]
.......
It is a manual work, but after opening an issue in github, it looks like they are not going to implement it
Maybe you can put a bit more of pressure there 🙂
d
Thanks. I was just making my
Iconic
object to get drawables using a key.
I also posted on the GitHub issue.