Search in sources :

Example 1 with Localizations

use of com.developmentontheedge.be5.metadata.model.Localizations in project be5 by DevelopmentOnTheEdge.

the class ProjectGenerator method setLanguages.

private void setLanguages(final Project project) {
    for (final String language : parameters.getLanguages()) {
        final Localizations localizations = project.getApplication().getLocalizations();
        final LanguageLocalizations languageLocalizations = new LanguageLocalizations(language, localizations);
        DataElementUtils.saveQuiet(languageLocalizations);
    }
}
Also used : LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) Localizations(com.developmentontheedge.be5.metadata.model.Localizations)

Example 2 with Localizations

use of com.developmentontheedge.be5.metadata.model.Localizations in project be5 by DevelopmentOnTheEdge.

the class Serialization method reloadLocalization.

public static LanguageLocalizations reloadLocalization(final Path file, final Localizations localizations) throws ReadException {
    checkProject(localizations.getProject());
    turnOffAutomaticSerialization();
    try {
        return new YamlDeserializer(new LoadContext()).reloadLocalization(file, localizations);
    } finally {
        turnOnAutomaticSerialization();
    }
}
Also used : YamlDeserializer(com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)

Example 3 with Localizations

use of com.developmentontheedge.be5.metadata.model.Localizations in project be5 by DevelopmentOnTheEdge.

the class ReadModelFromXmlTest method testWriteReadLocalizations.

@Test
public void testWriteReadLocalizations() throws Exception {
    final Project project = new Project("test");
    final Localizations localizations = project.getApplication().getLocalizations();
    localizations.addLocalization("en", "entity", Arrays.asList("topic"), "hello", "Hello!");
    localizations.addLocalization("de", "entity", Arrays.asList("topic", "topic2"), "hello", "Guten Tag!");
    localizations.addLocalization("it", "entity", Arrays.asList("topic2"), "hello", "Buon giorno!");
    final Path tempFolder = Files.createTempDirectory("be4-temp");
    Serialization.save(project, tempFolder);
    final Project project2 = Serialization.load(tempFolder);
    final Localizations localizations2 = project2.getApplication().getLocalizations();
    assertEquals("Hello!", localizations2.get("en").get("entity").elements().iterator().next().getValue());
    assertEquals("Guten Tag!", localizations2.get("de").get("entity").elements().iterator().next().getValue());
    assertEquals("Buon giorno!", localizations2.get("it").get("entity").elements().iterator().next().getValue());
    FileUtils.deleteRecursively(tempFolder);
}
Also used : Path(java.nio.file.Path) Project(com.developmentontheedge.be5.metadata.model.Project) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) Test(org.junit.Test)

Example 4 with Localizations

use of com.developmentontheedge.be5.metadata.model.Localizations in project be5 by DevelopmentOnTheEdge.

the class MetaImpl method getLocalization.

private String getLocalization(Project project, String language, String entity, Predicate<LocalizationElement> accept) {
    for (Module module : project.getModulesAndApplication()) {
        Localizations localizations = module.getLocalizations();
        LanguageLocalizations languageLocalizations = localizations.get(language);
        if (languageLocalizations == null)
            continue;
        EntityLocalizations entityLocalizations = languageLocalizations.get(entity);
        if (entityLocalizations == null)
            continue;
        for (LocalizationElement element : entityLocalizations.elements()) if (accept.test(element))
            return element.getValue();
    }
    return "";
}
Also used : EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) EntityLocalizations(com.developmentontheedge.be5.metadata.model.EntityLocalizations) LanguageLocalizations(com.developmentontheedge.be5.metadata.model.LanguageLocalizations) Localizations(com.developmentontheedge.be5.metadata.model.Localizations) Module(com.developmentontheedge.be5.metadata.model.Module) LocalizationElement(com.developmentontheedge.be5.metadata.model.LocalizationElement)

Aggregations

Localizations (com.developmentontheedge.be5.metadata.model.Localizations)3 LanguageLocalizations (com.developmentontheedge.be5.metadata.model.LanguageLocalizations)2 EntityLocalizations (com.developmentontheedge.be5.metadata.model.EntityLocalizations)1 LocalizationElement (com.developmentontheedge.be5.metadata.model.LocalizationElement)1 Module (com.developmentontheedge.be5.metadata.model.Module)1 Project (com.developmentontheedge.be5.metadata.model.Project)1 YamlDeserializer (com.developmentontheedge.be5.metadata.serialization.yaml.YamlDeserializer)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1