Class Internationalization
java.lang.Object
megamek.common.internationalization.Internationalization
Class to handle internationalization (you will find online material on that looking for i18n)
It makes use of some short names to make it easier to use since it is used in many places
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
getFormattedText
(String key, Object... args) Get a formatted localized string from the default bundlestatic String
getFormattedTextAt
(String bundleName, String key, Object... args) Get a formatted localized string from the default bundlestatic Internationalization
static String
Get a localized string from the default bundlestatic String
Get a localized string from a specific bundlestatic String
normalizeTextToASCII
(String text, boolean cache) Takes a string of Unicode text and attempts to convert it to an ASCII representation of that string.
-
Field Details
-
instance
-
-
Constructor Details
-
Internationalization
-
-
Method Details
-
getInstance
-
getTextAt
Get a localized string from a specific bundle- Parameters:
bundleName
- the name of the bundlekey
- the key of the string- Returns:
- the localized string
-
getText
Get a localized string from the default bundle- Parameters:
key
- the key of the string- Returns:
- the localized string
-
getFormattedText
Get a formatted localized string from the default bundle- Parameters:
key
- the key of the stringargs
- the arguments to format the string- Returns:
- the localized string
-
getFormattedTextAt
Get a formatted localized string from the default bundle- Parameters:
bundleName
- the name of the bundlekey
- the key of the stringargs
- the arguments to format the string- Returns:
- the localized string
-
normalizeTextToASCII
Takes a string of Unicode text and attempts to convert it to an ASCII representation of that string. Characters such as ø and ö will be converted to o.- Parameters:
text
- A String, such as Gún or Götterdämmerungcache
- Set to try to cache the result. The memoization cache can grow indefinitely, so care should be taken to not fill the cache with strings that might never be referenced again. For example, strings typed by the user shouldn't be cached, but unit names should be.- Returns:
- The normalized String, such as Gun or Gotterdammerung.
The returned string is not guaranteed to be only ASCII. Normalization will fail if there's no direct mapping from a character to its ASCII equivalent.
-