Im having trouble doing a translation in my project:
So I have this enum class:
enum class Theme(
val theme: ThemeL,
val name: String,
@DrawableRes val image: Int? = null,
){
THEME_1(
theme = ThemeL.Theme1,
humanName = "theme1 description",
image = R.drawable.theme1
),
THEME_2(
theme = ThemeL.Theme2,
humanName = "theme2 des",
image = R.drawable.theme1
),
}
My question is, I want that "humanName" can be translated to another languages,
in order to do that I created another strings.xml and defined the location I wanted in android studio, however I cant define here what should I put in "humaname = …" to achieve so.
my original strings.xml
<string name="theme1">theme one</string>
<string name="theme2">theme two</string>
and the one to be translated in portuguese
<string name="theme1">tema um</string>
<string name="theme2">tema dois</string>
2
Answers
To correctly translate strings into other languages, you need to create a folder for each language you wish to translate to in RES. For example, name the folder "values-pt". Within this folder, create an XML file called "strings" and place the strings you want to translate inside.
Instead of using String, you can use String id:
Then in composable function use String id: