Search in sources :

Example 11 with TableLocaleSource

use of org.javarosa.core.services.locale.TableLocaleSource 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");
    }
}
Also used : FormEntryPrompt(org.javarosa.form.api.FormEntryPrompt) DummyFormEntryPrompt(org.javarosa.core.model.test.DummyFormEntryPrompt) DummyFormEntryPrompt(org.javarosa.core.model.test.DummyFormEntryPrompt) TableLocaleSource(org.javarosa.core.services.locale.TableLocaleSource) Localizer(org.javarosa.core.services.locale.Localizer) QuestionDef(org.javarosa.core.model.QuestionDef)

Aggregations

TableLocaleSource (org.javarosa.core.services.locale.TableLocaleSource)11 Localizer (org.javarosa.core.services.locale.Localizer)10 UnregisteredLocaleException (org.javarosa.core.util.UnregisteredLocaleException)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IFormElement (org.javarosa.core.model.IFormElement)1 QuestionDef (org.javarosa.core.model.QuestionDef)1 AbstractTreeElement (org.javarosa.core.model.instance.AbstractTreeElement)1 TreeElement (org.javarosa.core.model.instance.TreeElement)1 DummyFormEntryPrompt (org.javarosa.core.model.test.DummyFormEntryPrompt)1 FormEntryPrompt (org.javarosa.form.api.FormEntryPrompt)1 Element (org.kxml2.kdom.Element)1