Search in sources :

Example 36 with Localizer

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");
    }
}
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)

Example 37 with Localizer

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