@Component
public final class I18n
extends java.lang.Object
initialize(). Then use getMessage(String) to use a language key from the
resource bundle corresponding to the specified locale. If no locale is provided during the launch
of ServerPackCreator, en_US is used by default.de/griefed/resources/lang/ -directory and be named using following pattern:
lang_{language code in lowercase}_{country code in lowercase}. For example:
lang_en_us.properties.lang-folder. If no file can be found for the specified locale,
ServerPackCreator tries to load language definitions from inside the JAR-file, from the resource
bundles. If the specified key can not be retrieved when calling getMessage(String), a
default is retrieved from the lang_en_us-bundle inside the JAR-file by default.| Constructor and Description |
|---|
I18n(ApplicationProperties injectedApplicationProperties)
Constructor for our I18n using the locale set in the
ApplicationProperties-instance
passed to this constructor. |
I18n(ApplicationProperties injectedApplicationProperties,
java.lang.String locale)
Constructor for our I18n with a given locale.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getMessage(java.lang.String languageKey)
Acquires a localized String for the provided language key from the initialized locale resource.
|
void |
initialize()
Initialize the I18n with en_us as the locale.
|
void |
initialize(java.lang.String locale)
Initializes the I18n with a provided locale.
|
@Autowired public I18n(ApplicationProperties injectedApplicationProperties)
ApplicationProperties-instance
passed to this constructor. If initialization with the provided
ApplicationProperties-instance fails, the I18n is initialized with the default locale
en_us.injectedApplicationProperties - Instance of ApplicationProperties required for
various different things.public I18n(ApplicationProperties injectedApplicationProperties, java.lang.String locale)
ApplicationProperties.
If this also fails, the default locale en_us is used.injectedApplicationProperties - Instance of ApplicationProperties required for
various different things.locale - String. The locale to initialize with.public void initialize(java.lang.String locale)
throws IncorrectLanguageException
locale - Locale to be used by application in this run.IncorrectLanguageException - Thrown if the language specified in the properties file is
not supported by ServerPackCreator or specified in the
invalid format.public void initialize()
public java.lang.String getMessage(java.lang.String languageKey)
languageKey - The language key to search for.