use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class TextFormTests method testPromptsWithLocalizer.
public void testPromptsWithLocalizer() {
Localizer l = new Localizer();
TableLocaleSource table = new TableLocaleSource();
l.addAvailableLocale("locale");
l.setDefaultLocale("locale");
table.setLocaleMapping("prompt;long", "loc: long text");
table.setLocaleMapping("prompt;short", "loc: short text");
table.setLocaleMapping("help", "loc: help text");
l.registerLocaleResource("locale", table);
l.setLocale("locale");
QuestionDef q = new QuestionDef();
q.setHelpTextID("help");
FormEntryPrompt fep = new DummyFormEntryPrompt(l, "prompt", q);
if (!"loc: long text".equals(fep.getLongText())) {
fail("Long text did not localize properly");
}
if (!"loc: short text".equals(fep.getShortText())) {
fail("Short text did not localize properly");
}
}
use of org.javarosa.core.services.locale.Localizer in project javarosa by opendatakit.
the class JavaRosaPropertyRules method allowableValues.
/**
* (non-Javadoc)
* @see org.javarosa.core.services.properties.IPropertyRules#allowableValues(String)
*/
public ArrayList<String> allowableValues(String propertyName) {
if (CURRENT_LOCALE.equals(propertyName)) {
Localizer l = Localization.getGlobalLocalizerAdvanced();
String[] locales = l.getAvailableLocales();
ArrayList<String> v = new ArrayList<String>(locales.length);
for (String locale : locales) {
v.add(locale);
}
return v;
}
return rules.get(propertyName);
}
Aggregations