* Translations:

- Use JVM language name if available
  - Correct Estonian language code from ee to et
This commit is contained in:
zzz
2013-01-29 13:44:36 +00:00
parent 95d0dc0419
commit 78dcfd830c
7 changed files with 41 additions and 5 deletions

View File

@@ -163,6 +163,29 @@ public abstract class Translate {
return rv;
}
/**
* Return the "display language", e.g. "English" for the language specified
* by langCode, using the current language.
* Uses translation if available, then JVM Locale.getDisplayLanguage() if available, else default param.
*
* @param langCode two-letter lower-case
* @param dflt e.g. "English"
* @since 0.9.5
*/
public static String getDisplayLanguage(String langCode, String dflt, I2PAppContext ctx, String bun) {
String curLang = getLanguage(ctx);
if (!"en".equals(curLang)) {
String rv = getString(dflt, ctx, bun);
if (!rv.equals(dflt))
return rv;
Locale curLocale = new Locale(curLang);
rv = (new Locale(langCode)).getDisplayLanguage(curLocale);
if (rv.length() > 0 && !rv.equals(langCode))
return rv;
}
return dflt;
}
/**
* Clear the cache.
* Call this after adding new bundles to the classpath.