Last active
October 12, 2016 10:56
-
-
Save RomkeVdMeulen/0536d9d01dbf37deffe138d01db03e07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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