我的 Message 类中有以下 Message 定义:
@DefaultMessage("{0,number} preceding items, and {1,number} " +
"followup items.")
@Description("Label showing the number of preceding items and " +
"follow-up items")
@AlternateMessage({
"none|one", "One follow-up item.",
"one|none", "One preceding item.",
"one|one", "One preceding item, and one follow-up item.",
"none|other", "{1,number} follow-up items.",
"other|none", "{0,number} preceding items.",
"one|other", "One preceding item, and {1,number} follow-up" +
" items.",
"other|one", "{0,number} preceding items, and one follow-up " +
"item."
})
String precedingAndFollowupItemCount(
@PluralCount(PluralRuleNoneOne.class) int precedingItemsCount,
@PluralCount(PluralRuleNoneOne.class) int followUpItemssCount);
我定义了 PluralRuleNonOne.class 如下
import com.google.gwt.i18n.client.impl.plurals.DefaultRule;
import com.google.gwt.i18n.client.impl.plurals.DefaultRule_0_1_n;
public final class PluralRuleNoneOne extends DefaultRule {
@Override
public PluralForm[] pluralForms() {
return DefaultRule_0_1_n.pluralForms();
}
@Override
public int select(final int n) {
return DefaultRule_0_1_n.select(n);
}
现在 gwt 编译器(带有 -extra)生成(除其他外)以下属性文件:
# Description: Label showing the number of preceding items and follow-up
items
# 0=precedingItemssCount (Plural Count), 1=followUpItemsCount (Plural Count)
# - Default plural form
BE52173166487BB95708A7E45EB0752B={0,number} preceding items, and {1,number}
follow-up items.
*# - plural form 'none': Count is 0
BE52173166487BB95708A7E45EB0752B[none]=
# - plural form 'one': Count is 1
BE52173166487BB95708A7E45EB0752B[one]=*
现在我想知道突出显示的属性代表什么。由于有两个参数,因此似乎不可能拥有像 BE52173166487BB95708A7E45EB0752B[none]=?
这样的属性此外,备用消息去了哪里,例如:
BE52173166487BB95708A7E45EB0752B[none|one]=一个后续项目。
这是 GWT 编译器中的错误还是我对 Message 类有一些误解?
感谢您的任何建议。
汉内斯
最佳答案
刚刚找到以下帖子:https://github.com/gwtproject/gwt/issues/7032解决了这个问题:
您需要在 Message 类中使用 @Generate(format = "com.google.gwt.i18n.server.PropertyCatalogFactory")。
关于java - GWT i8n 复数(在一个段落中使用 2 个复数形式不起作用 -> GWT 编译器中的错误?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46417401/