public abstract class ResourceBundle
Locale-specific resources with inherited-key lookup and cached loading. load("messages.Labels", Locale.FRANCE) searches classes before .properties files, from Labels_fr_FR to Labels_fr and Labels. If no localized candidate exists, the default locale is tried before the root. Only the language/country dimensions represented by Locale are considered. Roots follow ClassLoader search order; custom loaders can override resource lookup. Locale scripts and variants are not represented by Locale. Cached bundles are shared; subclasses must support concurrent reads and must not mutate published resource contents.
import klyn.i18n
messages = ResourceBundle.load("messages.Labels", Locale.FRANCE)
print(messages.getString("save"))
print(messages["save"])
print(messages.locale, messages.baseName)| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | baseNamebaseName as String |
Family name supplied to load(), without locale suffix or extension. |
| public readonly property | keys | Unique local and inherited keys in unspecified order. |
| public readonly property | localelocale as Locale |
Returns the locale actually loaded, not necessarily the requested locale. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | ResourceBundle | Creates the base of a resource-bundle subclass. |
| Modifier and Type | Member | Description |
|---|---|---|
| public static | clearCacheclearCache(loader as ClassLoader = null) as Void |
Invalidates cached bundles for a loader, or every loader when omitted. |
| public | containsKey | Tests for a key in this bundle or its parents without throwing if absent. |
| public | getString | Reads a String resource without converting objects of other types. |
| public | getStringArray | Reads a fixed-size String array without coercing lists or other values. |
| public static | loadload(notnull baseName as String, notnull locale as Locale = Locale.default, notnull loader as ClassLoader = ClassLoader.system) as ResourceBundle |
Loads and caches a resource family from the active class path. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | operator[](notnull key as String) as Object | Obtains an object, searching the parent chain only when locally absent. |