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