KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have some resource bundles packaged in my main jar widget_en.properties widget_de.properties I retrieve a resource bundle based on my default locale as folows ResourceBundle.getBundle("widget", Locale.getDefault()); But I want to present the user with a list of available languages supported so that can select a language that may be different to their computers default But I can't find a method in ResourceBundle that would list available locales, I don't want to hardcode a list as I may forget to update it when another resource bundle is added. EDIT As I only resource bundles for different language (I dont have country refinements) so I have got generated a list by iterating through all the known language codes and check for each one as a resource. String[]langs = Locale.getISOLanguages(); for(String lang:langs) { URL rb = ClassLoader.getSystemResource("widget_"+lang+".properties"); if(rb!=null) { System.out.println("Found:"+rb.toString()); } }
Tags (comma-separated)
Save Edits
Cancel