我目前正在开发一个Android应用程序,它大量使用android资源字符串进行国际化.每个字符串标识符名称都有特定的格式,例如
<string name="example.string.name.identifier">Example</string>
Run Code Online (Sandbox Code Playgroud)
在代码中我可以引用字符串:
R.string.example_string_name_identifier
Run Code Online (Sandbox Code Playgroud)
这适用于普通字符串.但是一旦我将这种格式用于多个标识符名称,我就会收到以下错误:
error: Error retrieving parent for item: No resource found that matches the given name 'example.plural.name'
Run Code Online (Sandbox Code Playgroud)
字符串复数定义如下:
<plurals name="example.plural.name.identifier">
<item quantity="one">Example</item>
<item quantity="other">Examples</item>
<item quantity="zero">Examples</item>
</plurals>
Run Code Online (Sandbox Code Playgroud)
在代码中我引用复数:
// _amount is a function parameter
String exampleString = getResources().getQuantityString(R.plurals.example_plural_name_identifier, _amount, _amount);
Run Code Online (Sandbox Code Playgroud)
不幸的是,我正在工作的公司,真的希望我坚持这种模式.有没有可能使用这个模式与字符串复数或我们必须重命名标识符?