use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testSetDefaultLocaleNotExists.
public void testSetDefaultLocaleNotExists() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
try {
l.setDefaultLocale(TEST_LOCALE);
fail("Set current locale to a non-existent locale");
} catch (UnregisteredLocaleException nsee) {
// expected
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testDestroyLocale.
public void testDestroyLocale() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
l.addAvailableLocale(TEST_LOCALE);
boolean result = l.destroyLocale(TEST_LOCALE);
if (!result || l.hasLocale(TEST_LOCALE)) {
fail("Locale not destroyed");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testGetNextLocale.
public void testGetNextLocale() {
Localizer l = new Localizer();
l.addAvailableLocale("test1");
l.addAvailableLocale("test2");
l.addAvailableLocale("test3");
if (l.getNextLocale() != null) {
fail("Unexpected next locale");
}
l.setDefaultLocale("test3");
if (!"test3".equals(l.getNextLocale())) {
fail("Unexpected next locale");
}
l.setDefaultLocale(null);
l.setLocale("test1");
if (!"test2".equals(l.getNextLocale())) {
fail("Unexpected next locale");
}
l.setLocale("test2");
if (!"test3".equals(l.getNextLocale())) {
fail("Unexpected next locale");
}
l.setLocale("test3");
if (!"test1".equals(l.getNextLocale())) {
fail("Unexpected next locale");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method buildLocalizer.
private Localizer buildLocalizer(int i, int j, int k, String ourLocale, String otherLocale) {
Localizer l = new Localizer(i / 2 == 0, i % 2 == 0);
TableLocaleSource firstLocale = new TableLocaleSource();
TableLocaleSource secondLocale = new TableLocaleSource();
if (j / 2 == 0 || "default".equals(ourLocale))
firstLocale.setLocaleMapping("textID", "text:" + ourLocale + ":base");
if (j % 2 == 0 || "default".equals(ourLocale))
firstLocale.setLocaleMapping("textID;form", "text:" + ourLocale + ":form");
if (otherLocale != null) {
if (k / 2 == 0 || "default".equals(otherLocale))
secondLocale.setLocaleMapping("textID", "text:" + otherLocale + ":base");
if (k % 2 == 0 || "default".equals(otherLocale))
secondLocale.setLocaleMapping("textID;form", "text:" + otherLocale + ":form");
}
l.addAvailableLocale(ourLocale);
l.registerLocaleResource(ourLocale, firstLocale);
if (otherLocale != null) {
l.addAvailableLocale(otherLocale);
l.registerLocaleResource(otherLocale, secondLocale);
}
if (l.hasLocale("default")) {
l.setDefaultLocale("default");
}
l.setLocale(ourLocale);
return l;
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class LocalizerTest method testSetToDefault.
public void testSetToDefault() {
Localizer l = new Localizer();
final String TEST_LOCALE = "test";
l.addAvailableLocale(TEST_LOCALE);
l.setDefaultLocale(TEST_LOCALE);
l.setToDefault();
if (!TEST_LOCALE.equals(l.getLocale())) {
fail("Could not set current locale to default");
}
}
Aggregations