There's a few ways we can deal with this sort of thing:
1. Use a clunky workaround like:
"{0} can contain only {1} child(ren) with entity {2}."
Clunky, but
it at least states the reason why the error/warning is
happening.
2. Reformulate [3] the sentence, perhaps like this:
"Parent has too many children with entity. Parent: {0}, Number
of children: {1}, Entity {2}"
I don't think this is a clear message,
compared to #1.
3. Use ICU's PluralFormat [4] support:
com.ibm.icu.text.MessageFormat.format(
"{1, plural, " +
"one {{0} can contain only # child with entity {2}.} " +
"other {{0} can contain only # children with entity {2}.}}",
new Object[] {parent, max, entity});
they encode the plural rules into one
string ?
4. Use Gettext's plural support[5], by using
gnu.gettext.GettextResource.ngettext() instead of
java.util.ResourceBundle.getString(). Actually, we can't really use
libgettext as is [6], but we could borrow the plural handling (it's
LGPL) and use it with Eclipse's Messages classes or ResourceBundles.
I18n.ngettext(Messages.class, "TOO_MANY_CHILDREN", a, b, c);
How much
code is that plural handling ?
Is it worth the trouble when we can't ensure all the plugins we use will
be able to use it ? (3rd party plugins would at most just use #3)
And how many places do we have to actually handle plural ?
I think option 2 deserves consideration. Yes, it's a workaround,
and
reformulating the sentences may be difficult, but I think the result
will often be clearer than the original, even in English. (If the
above example isn't clear, it's probably because I didn't understand
the original in context.) Using this workaround may avoid the need
for options 3 and 4.
Agreed, just need a better message ;)
/max