Search in sources :

Example 66 with Locale

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"));
    }
}
Also used : Locale(java.util.Locale)

Example 67 with Locale

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));
}
Also used : Locale(java.util.Locale)

Example 68 with Locale

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));
}
Also used : Locale(java.util.Locale) Test(org.junit.Test)

Example 69 with Locale

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));
}
Also used : Locale(java.util.Locale) Test(org.junit.Test)

Example 70 with Locale

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"));
}
Also used : Locale(java.util.Locale) Test(org.junit.Test)

Aggregations

Locale (java.util.Locale)5854 Test (org.junit.Test)902 HashMap (java.util.HashMap)548 GenericValue (org.apache.ofbiz.entity.GenericValue)504 ArrayList (java.util.ArrayList)486 Delegator (org.apache.ofbiz.entity.Delegator)484 GenericEntityException (org.apache.ofbiz.entity.GenericEntityException)398 IOException (java.io.IOException)313 LocalDispatcher (org.apache.ofbiz.service.LocalDispatcher)296 Date (java.util.Date)273 GenericServiceException (org.apache.ofbiz.service.GenericServiceException)271 Map (java.util.Map)244 BigDecimal (java.math.BigDecimal)214 SimpleDateFormat (java.text.SimpleDateFormat)198 ResourceBundle (java.util.ResourceBundle)197 File (java.io.File)166 LinkedList (java.util.LinkedList)158 ULocale (android.icu.util.ULocale)156 List (java.util.List)147 Test (org.junit.jupiter.api.Test)132