@Retention(value=RUNTIME) @Target(value=METHOD) @Documented public static @interface Messages.AlternateMessage
Example:
@DefaultMessage("You have {0} widgets.")
@AlternateMessage({"one", "You have one widget.")
String example(@PluralCount int count);
If multiple Messages.PluralCount
or Messages.Select
parameters are
supplied, the forms for each, in the order they appear in the parameter
list, are supplied separated by a vertical bar ("|"). Example:
Note that the number of permutations can grow quickly, and that the default
message is used when every
@DefaultMessage("You have {0} messages and {1} notifications.")
@AlternateMessage({
"=0|=0", "You have no messages or notifications."
"=0|one", "You have a notification."
"one|=0", "You have a message."
"one|one", "You have one message and one notification."
"other|one", "You have {0} messages and one notification."
"one|other", "You have one message and {1} notifications."
})
String messages(@PluralCount int msgCount,
@PluralCount int notifyCount);
Messages.PluralCount
or Messages.Select
would use
the "other" value.
public abstract String[] value
Messages.PluralCount
is used, or the matching value if Messages.Select
is
used. An example for a locale that has "none", "one", and "other" plural
forms:
@DefaultMessage("{0} widgets")
@AlternateMessage({"none", "No widgets", "one", "One widget"})
Note that the plural form "other" gets the translation specified in
@DefaultMessage
, as does any @Select
value not
listed.
If more than one way of selecting a translation exists, they will be
combined, separated with |
, in the order they are supplied as
arguments in the method. For example:
@DefaultMessage("{0} gave away their {2} widgets")
@AlternateMesssage({
"MALE|other", "{0} gave away his {2} widgets",
"FEMALE|other", "{0} gave away her {2} widgets",
"MALE|one", "{0} gave away his widget",
"FEMALE|one", "{0} gave away her widget",
"other|one", "{0} gave away their widget",
})
String giveAway(String name, @Select Gender gender,
@PluralCount int count);
Copyright © 2018. All rights reserved.