public class

DefaultRule

extends Object
implements Localizable PluralRule
java.lang.Object
   ↳ com.google.gwt.i18n.client.impl.plurals.DefaultRule
Known Direct Subclasses

Class Overview

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.

Summary

Public Constructors
DefaultRule()
Public Methods
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.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.google.gwt.i18n.client.PluralRule

Public Constructors

public DefaultRule ()

Public Methods

public PluralForm[] pluralForms ()

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.

public int select (int n)

Returns the plural form appropriate for this count. This method will be executed at runtime, so must be translatable.

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).