Package org.openstreetmap.josm.tools
Class I18n
java.lang.Object
org.openstreetmap.josm.tools.I18n
Internationalisation support.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static enumEnumeration of possible plural modes.static @interfaceThis annotates strings which do not permit a clean i18n. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Patternprivate static final Map<String,I18n.PluralMode> private static final Stringprivate static final Stringprivate static Stringprivate static final Localeprivate static final Stringprivate static final Stringprivate static I18n.PluralModeMap (english/locale) of plural stringsprivate static final StringMap (english/locale) of singular strings -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidI18n initialization for plugins.static StringEscapes the special i18n characters'{}with quotes.private static StringGet a list of all available JOSM Translations.getLocalizedLanguageName(String language) Returns the localized name of the given language and optional script.static StringgetLocalizedScript(String script) Returns the localized name of the given script.static LocaleReturns the original default locale found when the JVM started.Returns the map of plural translations.Returns the map of singular translations.private static Stringprivate static Stringprivate static StringgettextLazy(String text, String ctx) private static Stringprivate static URLgetTranslationFile(String lang) static booleanDetermines if a language exists for the given code.static voidinit()I18n initialization.static voidUpdates the default locale: overrides the numbering system, if defined in internal boundaries.xml for the current language/country.private static booleanload(InputStream en, InputStream tr, boolean add) private static booleanstatic StringMarks a string for translation (such that a script can harvest the translatable strings from the source files).static Stringprivate static intpluralEval(long n) static voidSets the default locale (seeLocale.setDefault(Locale)to the local given bylocalName.(package private) static Stringstatic StringTranslates some text for the current locale.static StringTranslates some text in a context for the current locale.static Stringstatic StringTranslates some text for the current locale and distinguishes betweensingularTextandpluralTextdepending onn.static StringTranslates some text in a context for the current locale and distinguishes betweensingularTextandpluralTextdepending onn.
-
Field Details
-
CORE_TRANS_DIRECTORY
- See Also:
-
PLUGIN_TRANS_DIRECTORY
- See Also:
-
pluralMode
-
loadedCode
-
strings
Map (english/locale) of singular strings -
pstrings
Map (english/locale) of plural strings -
originalLocale
-
languages
-
HIRAGANA
- See Also:
-
KATAKANA
- See Also:
-
LATIN
- See Also:
-
PINYIN
- See Also:
-
LATINPINYIN
- See Also:
-
ROMAJI
- See Also:
-
HANI
- See Also:
-
HANT
- See Also:
-
HANS
- See Also:
-
BOPOMOFO
- See Also:
-
LANGUAGE_NAMES
-
-
Constructor Details
-
I18n
private I18n()
-
-
Method Details
-
format
-
tr
Translates some text for the current locale. These strings are collected by a script that runs on the source code files. After translation, the localizations are distributed with the main program.
For example,tr("JOSM''s default value is ''{0}''.", val).
Usetrn(java.lang.String, java.lang.String, long, java.lang.Object...)for distinguishing singular from plural text, i.e., do not usetr(size == 1 ? "singular" : "plural")norsize == 1 ? tr("singular") : tr("plural")- Parameters:
text- the text to translate. Must be a string literal. (No constants or local vars.) Can be broken over multiple lines. An apostrophe ' must be quoted by another apostrophe.objects- the parameters for the string. Mark occurrences intextwith{0},{1}, ...- Returns:
- the translated string.
- See Also:
-
trc
Translates some text in a context for the current locale. There can be different translations for the same text within different contexts.- Parameters:
context- string that helps translators to find an appropriate translation fortext.text- the text to translate.- Returns:
- the translated string.
- See Also:
-
trcLazy
-
marktr
Marks a string for translation (such that a script can harvest the translatable strings from the source files). For example,String[] options = new String[] {marktr("up"), marktr("down")}; lbl.setText(tr(options[0]));- Parameters:
text- the string to be marked for translation.- Returns:
textunmodified.
-
marktrc
-
trn
Translates some text for the current locale and distinguishes betweensingularTextandpluralTextdepending onn.
For instance,trn("There was an error!", "There were errors!", i)ortrn("Found {0} error in {1}!", "Found {0} errors in {1}!", i, Integer.toString(i), url).- Parameters:
singularText- the singular text to translate. Must be a string literal. (No constants or local vars.) Can be broken over multiple lines. An apostrophe ' must be quoted by another apostrophe.pluralText- the plural text to translate. Must be a string literal. (No constants or local vars.) Can be broken over multiple lines. An apostrophe ' must be quoted by another apostrophe.n- a number to determine whethersingularTextorpluralTextis used.objects- the parameters for the string. Mark occurrences insingularTextandpluralTextwith{0},{1}, ...- Returns:
- the translated string.
- See Also:
-
trnc
public static String trnc(String context, String singularText, String pluralText, long n, Object... objects) Translates some text in a context for the current locale and distinguishes betweensingularTextandpluralTextdepending onn. There can be different translations for the same text within different contexts.- Parameters:
context- string that helps translators to find an appropriate translation fortext.singularText- the singular text to translate. Must be a string literal. (No constants or local vars.) Can be broken over multiple lines. An apostrophe ' must be quoted by another apostrophe.pluralText- the plural text to translate. Must be a string literal. (No constants or local vars.) Can be broken over multiple lines. An apostrophe ' must be quoted by another apostrophe.n- a number to determine whethersingularTextorpluralTextis used.objects- the parameters for the string. Mark occurrences insingularTextandpluralTextwith{0},{1}, ...- Returns:
- the translated string.
- See Also:
-
gettext
-
gettext
-
gettextLazy
-
gettextn
-
escape
Escapes the special i18n characters'{}with quotes.- Parameters:
msg- unescaped string- Returns:
- escaped string
- Since:
- 4477
-
getTranslationFile
-
getAvailableTranslations
Get a list of all available JOSM Translations.- Returns:
- an array of locale objects.
-
hasCode
Determines if a language exists for the given code.- Parameters:
code- The language code- Returns:
trueif a language exists,falseotherwise
-
setupJavaLocaleProviders
-
init
I18n initialization. -
addTexts
I18n initialization for plugins.- Parameters:
source- file path/name of the JAR or Zip file containing translation strings- Since:
- 4159
-
load
-
load
-
set
Sets the default locale (seeLocale.setDefault(Locale)to the local given bylocalName. Ignored if localeName is null. If the locale with namelocalNameisn't found the default local is set toen(english).- Parameters:
localeName- the locale name. Ignored if null.
-
initializeNumberingFormat
Updates the default locale: overrides the numbering system, if defined in internal boundaries.xml for the current language/country.- Since:
- 16109
-
pluralEval
-
getSingularTranslations
Returns the map of singular translations.- Returns:
- the map of singular translations.
- Since:
- 13761
-
getPluralTranslations
Returns the map of plural translations.- Returns:
- the map of plural translations.
- Since:
- 13761
-
getOriginalLocale
Returns the original default locale found when the JVM started. Used to guess real language/country of current user disregarding language chosen in JOSM preferences.- Returns:
- the original default locale found when the JVM started
- Since:
- 14013
-
getLocalizedScript
Returns the localized name of the given script. Only scripts used in the OSM database are known.- Parameters:
script- Writing system- Returns:
- the localized name of the given script, or null
- Since:
- 15501
-
getLocalizedLanguageName
Returns the localized name of the given language and optional script.- Parameters:
language- Language- Returns:
- the pair of localized name + known state of the given language, or null
- Since:
- 15501
-