use of org.terasology.persistence.TemplateEngineImpl in project Terasology by MovingBlocks.
the class TranslationSystemImpl method translate.
@Override
public String translate(String text, Locale otherLocale) {
TemplateEngine templateEngine = new TemplateEngineImpl(id -> {
ResourceUrn uri = new ResourceUrn(id);
SimpleUri projectUri = new SimpleUri(uri.getModuleName(), uri.getResourceName());
TranslationProject project = getProject(projectUri);
if (project != null) {
Optional<String> opt = project.translate(uri.getFragmentName(), otherLocale);
if (opt.isPresent()) {
return opt.get();
} else {
logger.warn("No translation for '{}'", id);
return "?" + uri.getFragmentName() + "?";
}
} else {
logger.warn("Invalid project id '{}'", id);
return "?" + uri.getFragmentName() + "?";
}
});
return templateEngine.transform(text);
}
Aggregations