diff options
author | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:21:33 +0000 |
---|---|---|
committer | tkellner <tkellner@174cde9d-5d70-4d2a-aa98-46368bc2aaf7> | 2013-04-10 19:21:33 +0000 |
commit | 7acc653f1982f2f839aadfe49f4277b160c94390 (patch) | |
tree | 242c03df43d1699fec03769c522d33205f99d38b /pdf-over-gui/src/main | |
parent | 275516dd3f8f8a97d9283e0f7024e413f2325d63 (diff) | |
download | pdf-over-7acc653f1982f2f839aadfe49f4277b160c94390.tar.gz pdf-over-7acc653f1982f2f839aadfe49f4277b160c94390.tar.bz2 pdf-over-7acc653f1982f2f839aadfe49f4277b160c94390.zip |
Only use configured locales
git-svn-id: https://joinup.ec.europa.eu/svn/pdf-over/trunk@279 174cde9d-5d70-4d2a-aa98-46368bc2aaf7
Diffstat (limited to 'pdf-over-gui/src/main')
3 files changed, 21 insertions, 6 deletions
diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java index e570a773..3879e79e 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Constants.java @@ -29,7 +29,7 @@ public class Constants { private static Display display = Display.getCurrent(); /** Supported locales */ - public static final Locale[] SUPPORTED_LOCALES = { Locale.ENGLISH, Locale.GERMAN }; + public static final Locale[] SUPPORTED_LOCALES = { Locale.GERMAN, Locale.ENGLISH }; /** Main window height */ public static final int MAINWINDOW_HEIGHT = 780; diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java index 77e2f764..b17e168a 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/Messages.java +++ b/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); diff --git a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java index 1e628342..ee44dad2 100644 --- a/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java +++ b/pdf-over-gui/src/main/java/at/asit/pdfover/gui/workflow/ConfigProviderImpl.java @@ -66,8 +66,8 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { private String defaultPassword = STRING_EMPTY; - private Locale locale = Locale.getDefault(); - private Locale signLocale = Locale.getDefault(); + private Locale locale = Messages.getDefaultLocale(); + private Locale signLocale = this.locale; private String emblem = STRING_EMPTY; @@ -593,7 +593,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { @Override public void setLocale(Locale locale) { if(locale == null) { - this.locale = Locale.getDefault(); + this.locale = Messages.getDefaultLocale(); } else { this.locale = locale; Locale.setDefault(locale); @@ -607,7 +607,7 @@ public class ConfigProviderImpl implements ConfigProvider, ConfigManipulator { @Override public void setSignLocale(Locale locale) { if(locale == null) { - this.signLocale = Locale.getDefault(); + this.signLocale = Messages.getDefaultLocale(); } else { this.signLocale = locale; } |