Class LanguageInfo
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDisplayName(Locale locale) Replies the display string used by JOSM for a given locale.static StringgetJavaLocaleCode(String localeName) Replies the locale code used by Java for a given locale.static StringReplies the JOSM locale code for the default locale.static StringgetJOSMLocaleCode(Locale locale) Replies the locale code used by JOSM for a given locale.static StringReplies the language prefix for use in manifests (with an underscore appended).Replies a list of language codes for local names.static StringReplies the language prefix for use in XML elements (with a dot appended).static LocaleReplies the locale used by Java for a given language code.static LocaleReplies the locale used by Java for a given language code.static String[]getOSMLocaleCodes(String prefix) Replies the OSM locale codes for the default locale.static String[]getOSMLocaleCodes(String prefix, Locale locale) Replies the locale codes used by OSM for a given locale.static StringReplies the wiki language prefix for the current locale.(package private) static StringgetWikiLanguagePrefix(Locale locale, LanguageInfo.LocaleType type) static StringReplies the wiki language prefix for the given locale.static booleanisBetterLanguage(String oldLanguage, String newLanguage) Check if a new language is better than a previous existing.
-
Constructor Details
-
LanguageInfo
private LanguageInfo()
-
-
Method Details
-
getWikiLanguagePrefix
Replies the wiki language prefix for the given locale. The wiki language prefix has the form 'Xy:' where 'Xy' is a ISO 639 language code in title case (or Xy_AB: for sub languages).- Parameters:
type- the type- Returns:
- the wiki language prefix or
nullforLanguageInfo.LocaleType.BASELANGUAGE, when base language is identical to default or english - Since:
- 5915
-
getWikiLanguagePrefix
-
getWikiLanguagePrefix
Replies the wiki language prefix for the current locale.- Returns:
- the wiki language prefix
- See Also:
-
getJOSMLocaleCode
Replies the JOSM locale code for the default locale.- Returns:
- the JOSM locale code for the default locale
- See Also:
-
getJOSMLocaleCode
Replies the locale code used by JOSM for a given locale.In most cases JOSM uses the 2-character ISO 639 language code (
Locale.getLanguage()to identify the locale of a localized resource, but in some cases it may use the programmatic name for locales, as replied byLocale.toString().For unknown country codes and variants this function already does fallback to internally known translations.
- Parameters:
locale- the locale. Replies "en" if null.- Returns:
- the JOSM code for the given locale
-
getOSMLocaleCodes
Replies the OSM locale codes for the default locale.- Parameters:
prefix- a prefix likename:.- Returns:
- the OSM locale codes for the default locale
- Since:
- 19045
- See Also:
-
getOSMLocaleCodes
Replies the locale codes used by OSM for a given locale.In most cases OSM uses the 2-character ISO 639 language code (
Locale.getLanguage()to identify the locale of a localized resource, but in some cases it may use the programmatic name for locales, as replied byLocale.toString().For unknown country codes and variants this function already does fallback to internally known translations.
- Parameters:
prefix- a prefix likename:.locale- the locale. Replies "en" if null.- Returns:
- the OSM codes for the given locale
- Since:
- 19045
-
getJavaLocaleCode
Replies the locale code used by Java for a given locale.In most cases JOSM and Java uses the same codes, but for some exceptions this is needed.
- Parameters:
localeName- the locale. Replies "en" if null.- Returns:
- the Java code for the given locale
- Since:
- 8232
-
getDisplayName
Replies the display string used by JOSM for a given locale.In most cases returns text replied by
Locale.getDisplayName(), for some locales an override is used (i.e. when unsupported by Java).- Parameters:
locale- the locale. Replies "en" if null.- Returns:
- the display string for the given locale
- Since:
- 8232
-
getLocale
Replies the locale used by Java for a given language code.Accepts JOSM and Java codes as input.
- Parameters:
localeName- the locale code.- Returns:
- the resulting locale
-
getLocale
Replies the locale used by Java for a given language code.Accepts JOSM, Java and POSIX codes as input.
- Parameters:
localeName- the locale code.useDefaultCountry- iftrue, the current locale country will be used if no country is specified- Returns:
- the resulting locale
- Since:
- 15547
-
isBetterLanguage
Check if a new language is better than a previous existing. Can be used in classes where multiple user supplied language marked strings appear and the best one is searched. Following priorities: current language, english, any other- Parameters:
oldLanguage- the language code of the existing stringnewLanguage- the language code of the new string- Returns:
- true if new one is better
- Since:
- 8091
-
getLanguageCodeXML
Replies the language prefix for use in XML elements (with a dot appended).- Returns:
- the XML language prefix
- See Also:
-
getLanguageCodeManifest
Replies the language prefix for use in manifests (with an underscore appended).- Returns:
- the manifest language prefix
- See Also:
-
getLanguageCodes
Replies a list of language codes for local names. Prefixes range from very specific to more generic.- lang_COUNTRY@variant of the current locale
- lang@variant of the current locale
- lang_COUNTRY of the current locale
- lang of the current locale
- Parameters:
l- the locale to use,nullfor default locale- Returns:
- list of codes
- Since:
- 8283
-