use of java.util.Locale in project head by mifos.
the class Localization method setLocaleMap.
private synchronized void setLocaleMap() {
if (LOCALE_MAP.isEmpty()) {
// These were the options in personnel language list (pre Mifos 2.2)
LOCALE_MAP.put((short) 1, Locale.UK);
// Icelandic
LOCALE_MAP.put((short) 2, new Locale("is", "IS"));
// Spanish
LOCALE_MAP.put((short) 3, SPANISH);
// French
LOCALE_MAP.put((short) 4, Locale.FRANCE);
// Chinese
LOCALE_MAP.put((short) 5, Locale.SIMPLIFIED_CHINESE);
// Swahili
LOCALE_MAP.put((short) 6, new Locale("sw", "KE"));
// Arabic
LOCALE_MAP.put((short) 7, new Locale("ar", "DZ"));
// Portuguese
LOCALE_MAP.put((short) 8, new Locale("pt", "AO"));
// Khmer
LOCALE_MAP.put((short) 9, new Locale("km", "KH"));
// Lola
LOCALE_MAP.put((short) 10, new Locale("lo", "LA"));
// Hungarian
LOCALE_MAP.put((short) 11, new Locale("hu", "HU"));
// Telugu
LOCALE_MAP.put((short) 12, new Locale("te", "IN"));
// Hindi
LOCALE_MAP.put((short) 13, new Locale("hi", "IN"));
LOCALE_MAP.put((short) 14, Locale.GERMAN);
// Russian
LOCALE_MAP.put((short) 15, new Locale("ru"));
// Georgian
LOCALE_MAP.put((short) 16, new Locale("ka"));
// Tamil
LOCALE_MAP.put((short) 17, new Locale("ta", "IN"));
}
}
use of java.util.Locale in project head by mifos.
the class Localization method readLoacaleSetting.
private void readLoacaleSetting() {
String lang = localeSetting.getLanguageCode().toLowerCase();
String country = localeSetting.getCountryCode().toUpperCase();
Locale locale = new Locale(lang, country);
if (!LOCALE_MAP.containsValue(locale)) {
configuredLocaleId = newLocaleId;
LOCALE_MAP.put(newLocaleId, locale);
} else {
configuredLocaleId = getLocaleId(locale);
}
configuredLocale = locale;
// workaround for MIFOS-5704: All unlocalized strings will be shown in English
Locale.setDefault(LOCALE_MAP.get(ENGLISH_LOCALE_ID));
}
use of java.util.Locale in project morphia by mongodb.
the class LocaleConverterTest method shouldEncodeAndDecodeNoLanguageLocale.
@Test
public void shouldEncodeAndDecodeNoLanguageLocale() {
// given
LocaleConverter converter = new LocaleConverter();
Locale expectedLocale = new Locale("", "FI", "VAR");
// when
Locale decodedLocale = (Locale) converter.decode(Locale.class, converter.encode(expectedLocale));
// then
assertThat(decodedLocale, is(expectedLocale));
}
use of java.util.Locale in project morphia by mongodb.
the class LocaleConverterTest method shouldEncodeAndDecodeSpecialVariantLocale.
@Test
public void shouldEncodeAndDecodeSpecialVariantLocale() {
// given
LocaleConverter converter = new LocaleConverter();
Locale expectedLocale = new Locale("fi", "FI", "VAR_SPECIAL");
// when
Locale decodedLocale = (Locale) converter.decode(Locale.class, converter.encode(expectedLocale));
// then
assertThat(decodedLocale, is(expectedLocale));
}
use of java.util.Locale in project morphia by mongodb.
the class LocaleConverterTest method shouldEncodeAndDecodeCustomLocale.
@Test
public void shouldEncodeAndDecodeCustomLocale() {
// given
LocaleConverter converter = new LocaleConverter();
Locale expectedLocale = new Locale("de", "DE", "bavarian");
// when
Locale decodedLocale = (Locale) converter.decode(Locale.class, converter.encode(expectedLocale));
// then
assertThat(decodedLocale, is(expectedLocale));
assertThat(decodedLocale.getLanguage(), is("de"));
assertThat(decodedLocale.getCountry(), is("DE"));
assertThat(decodedLocale.getVariant(), is("bavarian"));
}
Aggregations