@Component
public class LocalizationManager
extends java.lang.Object
initialize().
Then use getLocalizedString(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 getLocalizedString(String), a default
is retrieved from the lang_en_us-bundle inside the JAR-file by default.| Constructor and Description |
|---|
LocalizationManager()
Constructor for our LocalizationManager using the default locale en_us.
|
LocalizationManager(ApplicationProperties injectedApplicationProperties)
Constructor for our LocalizationManager using the locale set in the
ApplicationProperties-instance passed
to this constructor. |
LocalizationManager(ApplicationProperties injectedApplicationProperties,
java.lang.String locale)
Constructor for our LocalizationManager with a given locale.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getLocalizedString(java.lang.String languageKey)
Acquires a localized String for the provided language key from the initialized locale resource.
|
void |
initialize()
Initialize the LocalizationManager with en_us as the locale.
|
void |
initialize(ApplicationProperties applicationProperties)
Initializes the LocalizationManager with a provided localePropertiesFile.
|
void |
initialize(java.io.File propertiesFile)
Initializes the LocalizationManager with a provided localePropertiesFile.
|
void |
initialize(java.lang.String locale)
Initializes the LocalizationManager with a provided locale.
|
@Autowired public LocalizationManager(ApplicationProperties injectedApplicationProperties)
ApplicationProperties-instance passed
to this constructor. If initialization with the provided ApplicationProperties-instance fails, the
LocalizationManager is initialized with the default locale en_us.injectedApplicationProperties - Instance of ApplicationProperties required for various different things.public LocalizationManager(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 LocalizationManager()
public void initialize()
public void initialize(java.io.File propertiesFile)
throws IncorrectLanguageException
propertiesFile - Path to the locale properties file which specifies the language to use.IncorrectLanguageException - Thrown if the language specified in the properties file is not supported by
ServerPackCreator or specified in the invalid format.public void initialize(ApplicationProperties applicationProperties) throws IncorrectLanguageException
applicationProperties - Instance of ApplicationProperties containing the locale to use.IncorrectLanguageException - Thrown if the language specified in the properties file is not supported by
ServerPackCreator or specified in the invalid format.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 java.lang.String getLocalizedString(java.lang.String languageKey)
languageKey - The language key to search for.