Class I18NBundle
java.lang.Object
gaiasky.util.i18n.I18NBundle
Fork of Libgdx
I18NBundle that improves performance
by disabling exceptions by default and returning null.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic I18NBundlecreateBundle(com.badlogic.gdx.files.FileHandle baseFileHandle) Creates a new bundle using the specifiedbaseFileHandle, the default locale and the default encoding "UTF-8".static I18NBundlecreateBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, String encoding) Creates a new bundle using the specifiedbaseFileHandleandencoding; the default locale is used.static I18NBundlecreateBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, Locale locale) Creates a new bundle using the specifiedbaseFileHandleandlocale; the default encoding "UTF-8" is used.static I18NBundlecreateBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, Locale locale, String encoding) Creates a new bundle using the specifiedbaseFileHandle,localeandencoding.voidSets the value of all localized strings to String placeholder so hardcoded, unlocalized values can be easily spotted.Gets the string with the specified key from this bundle or one of its parent after replacing the given arguments if they occur.Gets a string for the given key from this bundle or one of its parents.Returns the locale of this bundle.static booleanReturns the flag indicating whether to use the simplified message pattern syntax (default is false).keys()Gets a key set of loaded properties.protected voidLoad the properties from the specified reader.static voidsetSimpleFormatter(boolean enabled) Sets the flag indicating whether to use the simplified message pattern.
-
Constructor Details
-
I18NBundle
public I18NBundle()
-
-
Method Details
-
getSimpleFormatter
public static boolean getSimpleFormatter()Returns the flag indicating whether to use the simplified message pattern syntax (default is false). This flag is always assumed to be true on GWT backend. -
setSimpleFormatter
public static void setSimpleFormatter(boolean enabled) Sets the flag indicating whether to use the simplified message pattern. The flag must be set before calling the factory methodscreateBundle. Notice that this method has no effect on the GWT backend where it's always assumed to be true. -
createBundle
Creates a new bundle using the specifiedbaseFileHandle, the default locale and the default encoding "UTF-8".- Parameters:
baseFileHandle- the file handle to the base of the bundle- Returns:
- a bundle for the given base file handle and the default locale
- Throws:
NullPointerException- ifbaseFileHandleisnullMissingResourceException- if no bundle for the specified base file handle can be found
-
createBundle
public static I18NBundle createBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, Locale locale) Creates a new bundle using the specifiedbaseFileHandleandlocale; the default encoding "UTF-8" is used.- Parameters:
baseFileHandle- the file handle to the base of the bundlelocale- the locale for which a bundle is desired- Returns:
- a bundle for the given base file handle and locale
- Throws:
NullPointerException- ifbaseFileHandleorlocaleisnullMissingResourceException- if no bundle for the specified base file handle can be found
-
createBundle
public static I18NBundle createBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, String encoding) Creates a new bundle using the specifiedbaseFileHandleandencoding; the default locale is used.- Parameters:
baseFileHandle- the file handle to the base of the bundleencoding- the character encoding- Returns:
- a bundle for the given base file handle and locale
- Throws:
NullPointerException- ifbaseFileHandleorencodingisnullMissingResourceException- if no bundle for the specified base file handle can be found
-
createBundle
public static I18NBundle createBundle(com.badlogic.gdx.files.FileHandle baseFileHandle, Locale locale, String encoding) Creates a new bundle using the specifiedbaseFileHandle,localeandencoding.- Parameters:
baseFileHandle- the file handle to the base of the bundlelocale- the locale for which a bundle is desiredencoding- the character encoding- Returns:
- a bundle for the given base file handle and locale
- Throws:
NullPointerException- ifbaseFileHandle,localeorencodingisnullMissingResourceException- if no bundle for the specified base file handle can be found
-
load
Load the properties from the specified reader.- Parameters:
reader- the reader- Throws:
IOException- if an error occurred when reading from the input stream.
-
getLocale
Returns the locale of this bundle. This method can be used after a call tocreateBundle()to determine whether the resource bundle returned really corresponds to the requested locale or is a fallback.- Returns:
- the locale of this bundle
-
contains
-
get
-
keys
-
format
Gets the string with the specified key from this bundle or one of its parent after replacing the given arguments if they occur.- Parameters:
key- the key for the desired stringargs- the arguments to be replaced in the string associated to the given key.- Returns:
- the string for the given key formatted with the given arguments
- Throws:
NullPointerException- ifkeyisnullMissingResourceException- if no string for the given key can be found
-
debug
Sets the value of all localized strings to String placeholder so hardcoded, unlocalized values can be easily spotted. The I18NBundle won't be able to reset values after calling debug and should only be using during testing.
-