Skip to content

Instantly share code, notes, and snippets.

@RomkeVdMeulen
Last active October 12, 2016 10:56
Show Gist options
  • Save RomkeVdMeulen/0536d9d01dbf37deffe138d01db03e07 to your computer and use it in GitHub Desktop.
Save RomkeVdMeulen/0536d9d01dbf37deffe138d01db03e07 to your computer and use it in GitHub Desktop.
@Singleton
public class FrontendTextBean {
@EJB
private TextCache textCache;
private Set<String> textkeys = new HashSet<>();
@PostConstruct
public void init() {
try (BufferedReader r = new BufferedReader(new InputStreamReader(
this.getClass().getResourceAsStream("/META-INF/frontend-textkeys.conf")))) {
String key;
while ((key = r.readLine()) != null) {
textkeys.add(key);
}
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public Map<String, String> getTranslations(String lang) {
Map<String, String> translations = new HashMap<>();
for (String key : tekstkeys) {
String translation = textCache.getTranslation(lang, key));
if (translation != null) {
translations.put(key, translation);
}
}
return translations;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment