Modifier and Type | Class and Description |
---|---|
private static class |
I18n.PluralMode
Enumeration of possible plural modes.
|
static interface |
I18n.QuirkyPluralString
This annotates strings which do not permit a clean i18n.
|
Modifier and Type | Field and Description |
---|---|
private static String[] |
javaInternalMessageKeys |
private static Map<String,I18n.PluralMode> |
languages |
private static String |
loadedCode |
private static I18n.PluralMode |
pluralMode |
private static Map<String,String[]> |
pstrings |
private static Map<String,String> |
strings |
static Locale |
SystemLocale
store the original system locale for further use
|
Modifier | Constructor and Description |
---|---|
private |
I18n() |
Modifier and Type | Method and Description |
---|---|
static void |
addTexts(File source) |
static String |
escape(String msg) |
static Locale[] |
getAvailableTranslations()
Get a list of all available JOSM Translations.
|
private static String |
gettext_lazy(String text,
String ctx) |
private static String |
gettext(String text,
String ctx) |
private static String |
gettext(String text,
String ctx,
boolean lazy) |
private static String |
gettextn(String text,
String plural,
String ctx,
long num) |
static FeatureAdapter.TranslationAdapter |
getTranslationAdapter() |
private static URL |
getTranslationFile(String lang) |
static boolean |
hasCode(String code)
Determines if a language exists for the given code.
|
static void |
init()
I18n initialization.
|
private static boolean |
load(InputStream en,
InputStream tr,
boolean add) |
private static boolean |
load(String l) |
static String |
marktr(String text)
Marks a string for translation (such that a script can harvest
the translatable strings from the source files).
|
static String |
marktrc(String context,
String text) |
private static int |
pluralEval(long n) |
static void |
set(String localeName)
Sets the default locale (see
Locale.setDefault(Locale) to the local
given by localName . |
static void |
setupLanguageFonts()
Setup special font for Khmer script, as the default Java fonts do not display these characters.
|
static String |
tr(String text,
Object... objects)
Translates some text for the current locale.
|
static void |
translateJavaInternalMessages()
Localizations for file chooser dialog.
|
static String |
trc_lazy(String context,
String text) |
static String |
trc(String context,
String text)
Translates some text in a context for the current locale.
|
static String |
trn(String singularText,
String pluralText,
long n,
Object... objects)
Translates some text for the current locale and distinguishes between
singularText and pluralText depending on n . |
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 between
singularText and pluralText depending on n . |
private static volatile I18n.PluralMode pluralMode
private static volatile String loadedCode
public static final Locale SystemLocale
private static final String[] javaInternalMessageKeys
private static Map<String,I18n.PluralMode> languages
private I18n()
public static String tr(String text, Object... objects)
tr("JOSM''s default value is ''{0}''.", val)
.
trn(java.lang.String, java.lang.String, long, java.lang.Object...)
for distinguishing singular from plural text, i.e.,
do not use tr(size == 1 ? "singular" : "plural")
nor
size == 1 ? tr("singular") : tr("plural")
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 in text
with {0}
, {1}
, ...trn(java.lang.String, java.lang.String, long, java.lang.Object...)
,
trc(java.lang.String, java.lang.String)
,
trnc(java.lang.String, java.lang.String, java.lang.String, long, java.lang.Object...)
public static String trc(String context, String text)
context
- string that helps translators to find an appropriate
translation for text
.text
- the text to translate.tr(java.lang.String, java.lang.Object...)
,
trn(java.lang.String, java.lang.String, long, java.lang.Object...)
,
trnc(java.lang.String, java.lang.String, java.lang.String, long, java.lang.Object...)
public static String marktr(String text)
String[] options = new String[] {marktr("up"), marktr("down")};
lbl.setText(tr(options[0]));
text
- the string to be marked for translation.text
unmodified.public static String trn(String singularText, String pluralText, long n, Object... objects)
singularText
and pluralText
depending on n
.
trn("There was an error!", "There were errors!", i)
or
trn("Found {0} error in {1}!", "Found {0} errors in {1}!", i, Integer.toString(i), url)
.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 whether singularText
or pluralText
is used.objects
- the parameters for the string.
Mark occurrences in singularText
and pluralText
with {0}
, {1}
, ...tr(java.lang.String, java.lang.Object...)
,
trc(java.lang.String, java.lang.String)
,
trnc(java.lang.String, java.lang.String, java.lang.String, long, java.lang.Object...)
public static String trnc(String context, String singularText, String pluralText, long n, Object... objects)
singularText
and pluralText
depending on n
.
There can be different translations for the same text within different contexts.context
- string that helps translators to find an appropriate
translation for text
.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 whether singularText
or pluralText
is used.objects
- the parameters for the string.
Mark occurrences in singularText
and pluralText
with {0}
, {1}
, ...tr(java.lang.String, java.lang.Object...)
,
trc(java.lang.String, java.lang.String)
,
trn(java.lang.String, java.lang.String, long, java.lang.Object...)
private static String gettext_lazy(String text, String ctx)
private static URL getTranslationFile(String lang)
public static Locale[] getAvailableTranslations()
public static boolean hasCode(String code)
code
- The language codetrue
if a language exists, false
otherwisepublic static void init()
private static boolean load(InputStream en, InputStream tr, boolean add)
public static void set(String localeName)
Locale.setDefault(Locale)
to the local
given by localName
.
Ignored if localeName is null. If the locale with name localName
isn't found the default local is set to en (english).localeName
- the locale name. Ignored if null.public static void translateJavaInternalMessages()
private static int pluralEval(long n)
public static FeatureAdapter.TranslationAdapter getTranslationAdapter()
public static void setupLanguageFonts()