diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2012-11-12 21:57:42 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2012-11-12 21:57:42 +0100 |
commit | 7eda125f02b3a3b6aa0c2e38525627c358cc347f (patch) | |
tree | d9b38e289e3c320433c0446c0a21dae0b39a5c81 /trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java | |
parent | 774532820a5c5aab3dcfab1cae92155de7b90475 (diff) | |
download | pdf-over-7eda125f02b3a3b6aa0c2e38525627c358cc347f.tar.gz pdf-over-7eda125f02b3a3b6aa0c2e38525627c358cc347f.tar.bz2 pdf-over-7eda125f02b3a3b6aa0c2e38525627c358cc347f.zip |
Only use configured locales
Diffstat (limited to 'trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java')
-rw-r--r-- | trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java index 77e2f764..b17e168a 100644 --- a/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java +++ b/trunk/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java @@ -41,12 +41,25 @@ public class Messages { //private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle // .getBundle(BUNDLE_NAME); - private static Locale currentLocale = Locale.getDefault(); + private static Locale currentLocale = getDefaultLocale(); private Messages() { } /** + * Get the closest match to the system default Locale out of the supported locales + * @return the default locale + */ + public static Locale getDefaultLocale() { + Locale ld = Locale.getDefault(); + for (Locale l : Constants.SUPPORTED_LOCALES) { + if (l.equals(ld) || l.getLanguage().equals(ld.getLanguage())) + return l; + } + return Constants.SUPPORTED_LOCALES[0]; + } + + /** * Sets the currently used locals * @param locale */ @@ -56,9 +69,11 @@ public class Messages { private static ResourceBundle getBundle(Locale locale) { if(!bundles.containsKey(locale)) { + log.debug("Loading resource bundle for " + locale); //$NON-NLS-1$ ResourceBundle tmp = null; try { tmp = ResourceBundle.getBundle(BUNDLE_NAME, locale); + log.debug("Received bundle for " + tmp.getLocale()); //$NON-NLS-1$ } catch(Exception e) { log.error("NO RESOURCE BUNDLE FOR " + locale.toString(), e); //$NON-NLS-1$ tmp = ResourceBundle.getBundle(BUNDLE_NAME); |