iGE*_*GEL 10 android internationalization
我知道在Android中支持18n应用程序,但是我可以为这样的字符串提供参数吗?在Rails中,我可以这样做:
en:
hello: "Hello %{name}! You've got %{count} messages."
t("hello", name: "Klaus", count: 5)
Run Code Online (Sandbox Code Playgroud)
在Android中有类似的东西,还是我自己必须这样做?
Mar*_*jøl 12
要详细说明Heiko的答案,并展示您的具体示例,如果您想要有多个字符串,则需要对它们进行编号:
<string name="hello">Hello %1$s! You've got %2$d messages.</string>
Run Code Online (Sandbox Code Playgroud)
这样您就可以在每次翻译中切换字符串的顺序.使用它将是:
String hello = getString(R.strings.hello, "Klaus", 5);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2448 次 |
| 最近记录: |