Java Reference
In-Depth Information
};
}
This bundle covers the English-language locale en . It provides specific
values for each localizable string. The next bundle uses the inheritance
feature:
public class GlobalRes_en_AU extends ListResourceBundle {
// mostly like basic English - our parent bundle
public Object[][] getContents() { return contents; }
private static final Object[][] contents = {
{ GlobalRes.HELLO, "G'day" },
};
}
This bundle is for English speakers from Australia ( AU ). It provides
a more colloquial version of the HELLO string and inherits all other
strings from the general English locale GlobalRes_en . Whenever a re-
source bundle is instantiated, its parent chain is established. This pro-
ceeds by successively dropping the variant, country, and language com-
ponents from the base bundle name and instantiating those bundles if
they exist. If they do exist then setParent is called on the preceding
bundle passing the new bundle as the parent. So in our example, when
GlobalRes_en_AU is created, the system will create GlobalRes_en and set it
as the parent of GlobalRes_en_AU . In turn, the parent of GlobalRes_en will
be the base bundle GlobalRes .
Given these classes, someone with an English-language locale ( en )
would get the values returned by GlobalRes_en unless the locale also
specified the country Australia ( AU ), in which case values from Glob-
alRes_en_AU would be used. Everyone else would see those in GlobalRes .
 
Search WWH ::




Custom Search