Search in sources :

Example 6 with Localizer

use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.

the class LocalizerTest method testSetCurrentLocaleExists.

public void testSetCurrentLocaleExists() {
    Localizer l = new Localizer();
    final String TEST_LOCALE = "test";
    l.addAvailableLocale(TEST_LOCALE);
    l.setLocale(TEST_LOCALE);
    if (!TEST_LOCALE.equals(l.getLocale())) {
        fail("Did not properly set current locale");
    }
}
Also used : Localizer(org.javarosa.core.services.locale.Localizer)

Example 7 with Localizer

use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.

the class LocalizerTest method testUnsetCurrentLocale.

public void testUnsetCurrentLocale() {
    Localizer l = new Localizer();
    final String TEST_LOCALE = "test";
    l.addAvailableLocale(TEST_LOCALE);
    l.setLocale(TEST_LOCALE);
    try {
        l.setLocale(null);
        fail("Able to unset current locale");
    } catch (UnregisteredLocaleException nsee) {
    // expected
    }
}
Also used : Localizer(org.javarosa.core.services.locale.Localizer) UnregisteredLocaleException(org.javarosa.core.util.UnregisteredLocaleException)

Example 8 with Localizer

use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.

the class LocalizerTest method testAddLocale.

public void testAddLocale() {
    Localizer l = new Localizer();
    final String TEST_LOCALE = "test";
    if (l.hasLocale(TEST_LOCALE)) {
        fail("Localizer reports it contains non-existent locale");
    }
    boolean result = l.addAvailableLocale(TEST_LOCALE);
    if (!result) {
        fail("Localizer failed to add new locale");
    }
    if (!l.hasLocale(TEST_LOCALE)) {
        fail("Localizer reports it does not contain newly added locale");
    }
    OrderedMap<String, String> localeData = l.getLocaleData(TEST_LOCALE);
    if (localeData == null || localeData.size() != 0) {
        fail("Newly created locale not empty (or undefined)");
    }
}
Also used : Localizer(org.javarosa.core.services.locale.Localizer)

Example 9 with Localizer

use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.

the class LocalizerTest method testGetLocaleMap.

public void testGetLocaleMap() {
    Localizer l = new Localizer();
    final String TEST_LOCALE = "test";
    l.addAvailableLocale(TEST_LOCALE);
    if (!l.getLocaleMap(TEST_LOCALE).equals(l.getLocaleData(TEST_LOCALE))) {
        fail();
    }
}
Also used : Localizer(org.javarosa.core.services.locale.Localizer)

Example 10 with Localizer

use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.

the class LocalizerTest method testEmpty.

public void testEmpty() {
    Localizer l = new Localizer();
    String[] locales = l.getAvailableLocales();
    if (locales == null || locales.length > 0) {
        fail("New localizer not empty");
    }
    String currentLocale = l.getLocale();
    if (currentLocale != null) {
        fail("New localizer has locale set");
    }
    String defaultLocale = l.getDefaultLocale();
    if (defaultLocale != null) {
        fail("New localizer has default locale set");
    }
}
Also used : Localizer(org.javarosa.core.services.locale.Localizer)

Aggregations

Localizer (org.javarosa.core.services.locale.Localizer)37 TableLocaleSource (org.javarosa.core.services.locale.TableLocaleSource)10 UnregisteredLocaleException (org.javarosa.core.util.UnregisteredLocaleException)7 ArrayList (java.util.ArrayList)3 QuestionDef (org.javarosa.core.model.QuestionDef)3 FormEntryController (org.javarosa.form.api.FormEntryController)2 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)2 List (java.util.List)1 IDataReference (org.javarosa.core.model.IDataReference)1 IFormElement (org.javarosa.core.model.IFormElement)1 Condition (org.javarosa.core.model.condition.Condition)1 IConditionExpr (org.javarosa.core.model.condition.IConditionExpr)1 Recalculate (org.javarosa.core.model.condition.Recalculate)1 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)1 DataInstance (org.javarosa.core.model.instance.DataInstance)1 TreeElement (org.javarosa.core.model.instance.TreeElement)1 DummyFormEntryPrompt (org.javarosa.core.model.test.DummyFormEntryPrompt)1 InvalidReferenceException (org.javarosa.core.reference.InvalidReferenceException)1 Reference (org.javarosa.core.reference.Reference)1 ResourceReferenceFactory (org.javarosa.core.reference.ResourceReferenceFactory)1