com.google.gwt.i18n.client.impl.plurals
Class DefaultRule

java.lang.Object
  extended by com.google.gwt.i18n.client.impl.plurals.DefaultRule
All Implemented Interfaces:
Localizable, PluralRule
Direct Known Subclasses:
DefaultRule_af, DefaultRule_am, DefaultRule_ar, DefaultRule_az, DefaultRule_be, DefaultRule_bg, DefaultRule_bh, DefaultRule_bn, DefaultRule_bo, DefaultRule_bs, DefaultRule_ca, DefaultRule_cs, DefaultRule_cy, DefaultRule_da, DefaultRule_de, DefaultRule_dz, DefaultRule_el, DefaultRule_en, DefaultRule_eo, DefaultRule_es, DefaultRule_et, DefaultRule_eu, DefaultRule_fa, DefaultRule_fi, DefaultRule_fil, DefaultRule_fo, DefaultRule_fr, DefaultRule_fur, DefaultRule_fy, DefaultRule_ga, DefaultRule_gl, DefaultRule_gu, DefaultRule_guw, DefaultRule_ha, DefaultRule_he, DefaultRule_hi, DefaultRule_hr, DefaultRule_hu, DefaultRule_id, DefaultRule_is, DefaultRule_it, DefaultRule_ja, DefaultRule_jv, DefaultRule_ka, DefaultRule_km, DefaultRule_kn, DefaultRule_ko, DefaultRule_ku, DefaultRule_lb, DefaultRule_ln, DefaultRule_lt, DefaultRule_lv, DefaultRule_mg, DefaultRule_mk, DefaultRule_ml, DefaultRule_mn, DefaultRule_mr, DefaultRule_ms, DefaultRule_mt, DefaultRule_nah, DefaultRule_nb, DefaultRule_ne, DefaultRule_nl, DefaultRule_nn, DefaultRule_no, DefaultRule_nso, DefaultRule_om, DefaultRule_or, DefaultRule_pa, DefaultRule_pap, DefaultRule_pl, DefaultRule_ps, DefaultRule_pt, DefaultRule_pt_br, DefaultRule_ro, DefaultRule_ru, DefaultRule_se, DefaultRule_sk, DefaultRule_sl, DefaultRule_smi, DefaultRule_smj, DefaultRule_sms, DefaultRule_so, DefaultRule_sq, DefaultRule_sr, DefaultRule_sv, DefaultRule_sw, DefaultRule_ta, DefaultRule_te, DefaultRule_th, DefaultRule_ti, DefaultRule_tk, DefaultRule_tr, DefaultRule_uk, DefaultRule_ur, DefaultRule_vi, DefaultRule_wa, DefaultRule_zh, DefaultRule_zu

public class DefaultRule
extends java.lang.Object
implements Localizable, PluralRule

Default implementation of plural rules. The i18n generator will substitute subclasses of this class, which may reside anywhere in the package hierarchy, based on the locale. See Localizable for more details on this process. The default implementation here always selects the default form. To define a new language, simply declare a subclass of this class that is named with the locale you want to specify, such as DefaultRule_en_uk for English spoken in the UK (note the lower-cased tag). This is an implementation of the language pluralization rules described at http://translate.sourceforge.net/wiki/l10n/pluralforms Eventually, all these rules will be machine generated from Unicode's CLDR, perhaps with some additional data that isn't kept there if necessary. The current subclasses are defined just to get reasonable plural support for most of the common languages -- in particular, you should not rely on particular keywords for the plural forms of a given language.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.google.gwt.i18n.client.PluralRule
PluralRule.PluralForm
 
Constructor Summary
DefaultRule()
           
 
Method Summary
 PluralRule.PluralForm[] pluralForms()
          Returns the list of values which are valid for this rule.
 int select(int n)
          Returns the plural form appropriate for this count.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRule

public DefaultRule()
Method Detail

pluralForms

public PluralRule.PluralForm[] pluralForms()
Description copied from interface: PluralRule
Returns the list of values which are valid for this rule. The default or "other" plural form must be first in the list with an index of 0 -- this form will be used if no other form applies and is also mapped to the default text for a given message. This method will be executed at compile time and may not contain any references, even indirectly, to JSNI methods.

Specified by:
pluralForms in interface PluralRule

select

public int select(int n)
Description copied from interface: PluralRule
Returns the plural form appropriate for this count. This method will be executed at runtime, so must be translatable.

Specified by:
select in interface PluralRule
Parameters:
n - count of items to choose plural form for
Returns:
the plural form to use (must be a valid index into the array returned by pluralForms).