Issue
In Android strings.xml file I have a string resource with two parameters like this:
<string name="menu_greeting_loggged_in">Hello %1$s %2$s</string>
The problem is that I have a Android lint warning saying:
Placeholder name is missing.
Explain issue shows nothing.
How to fix this warning and what does it mean? How can I add the placeholder name required?
Solution
I accidentally stumbled upon what I think may be the solution. Just add <xliff:g>
tags around the placeholder parameter, like this:
<xliff:g id="HOURS" example="2 hours">%1$s</xliff:g>
So for your example above, replace the string definition with e.g.:
<string name="menu_greeting_loggged_in">Hello
<xliff:g id="first_name" example="Jane">%1$s</xliff:g>
<xliff:g id="last_name" example="Doe">%2$s</xliff:g>
</string>
The use of <xliff:g>
placeholder tags is explained in the Android Localization Checklist (look under the section "Mark message parts that should not be translated").
Answered By - Eric Hansander
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.