Lukasz Kalnik
01/17/2025, 10:03 AMformatArgs
) in stringResource()
?
E.g.
<string name="generic_input">Please insert %s</string>
<string name="length_input">length</string>
Would nested `stringResource`s work?
Text(
text = stringResource(R.string.generic_input, stringResource(R.string.length_input))
)
David
01/17/2025, 10:07 AMLukasz Kalnik
01/17/2025, 10:08 AMDavid
01/17/2025, 10:08 AMVlad
01/17/2025, 12:26 PMBut it is hard to tell if all languages would follow the pattern
Not sure how exactly this related to the topic.
<string name="generic_input">%s insertio in someOtherLanguage </string>
will still work.
It also becomes hard for translators to follow since everything is references.
Is there another way?David
01/17/2025, 12:45 PM%s
is used in different places it might suppose to have different format in different languages depending where in a sentence the phrase/word is used.
The alternative is to make them more flat. Use %s
& %d
for cases where there is strict dynamic input from code. E.g a value, day of week, name of something etc.Vlad
01/17/2025, 12:46 PM<string name="generic_input">Please insert %s</string>
Italiano:
<string name="generic_input">%s insertio in someOtherLanguage </string>
David
01/17/2025, 12:49 PM%s
may be different in different languages, and if you reuse %s
across multiple sentences it won't work in all places.Vlad
01/17/2025, 12:50 PMDavid
01/17/2025, 12:54 PMPlease insert length
You can imagine length would be substituted with height
, weight
or something else: It can be 3 different strings:
Please insert height
Please insert weight
Please insert length
But if your scenario is Your score is %d points
then it it obviously you cant have separate string for that. My point is, overly nesting strings, without a clear reason too is not good. A good warning flag is when you start inserting longer sentences or phrases into other phrases.David
01/17/2025, 12:56 PM