From 3920c2fcb879320dff1c20de125e62b41bd750b3 Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Thu, 20 Mar 2014 15:49:19 +0100 Subject: initial language changes for gui and errors --- .../config/ConfigurationProvider.java | 8 ++++ .../id/configuration/helper/LanguageHelper.java | 52 +++++++++++++++++++--- 2 files changed, 53 insertions(+), 7 deletions(-) (limited to 'id/ConfigWebTool/src/main/java') diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java index fdd566888..2dce3534f 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/config/ConfigurationProvider.java @@ -377,6 +377,14 @@ public class ConfigurationProvider { public String getMailOAActivationSubject() { return props.getProperty("general.mail.createOArequest.isactive.subject"); } + + public String getDefaultLanguage() { + try { + return props.getProperty("general.defaultlanguage").toLowerCase(); + } catch (Exception ex) { + return "de"; + } + } public String getMailOAActivationTemplate() throws ConfigurationException { String url = props.getProperty("general.mail.createOArequest.isactive.template"); diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java index a2f0628eb..73b2708ae 100644 --- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java +++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java @@ -23,6 +23,10 @@ package at.gv.egovernment.moa.id.configuration.helper; +import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; +import at.gv.egovernment.moa.id.configuration.exception.ConfigurationException; +import at.gv.egovernment.moa.logging.Logger; + import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; @@ -34,9 +38,44 @@ public class LanguageHelper { private static ResourceBundle errorRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); private static ResourceBundle guiRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); - - public static String getGUIString(String code, HttpServletRequest request) { - return guiRes_DE.getString(code); + + private static ResourceBundle errorRes_EN = ResourceBundle.getBundle("applicationResources_en", Locale.ENGLISH); + private static ResourceBundle guiRes_EN = ResourceBundle.getBundle("applicationResources_en", Locale.ENGLISH); + + private static ResourceBundle errorLanguage() { + Logger.setHierarchy("moa.id.configuration"); + try { + ConfigurationProvider configurationProvider = ConfigurationProvider.getInstance(); + if (configurationProvider.getDefaultLanguage().equals("en")) { + return errorRes_EN; + } else { + return errorRes_DE; + } + } catch (ConfigurationException e) { + Logger.error("Configuration exception while getting ConfigurationProvider instance"); + e.printStackTrace(); + return errorRes_DE; + } + } + + private static ResourceBundle guiLanguage() { + Logger.setHierarchy("moa.id.configuration"); + try { + ConfigurationProvider configurationProvider = ConfigurationProvider.getInstance(); + if (configurationProvider.getDefaultLanguage().equals("en")) { + return guiRes_EN; + } else { + return guiRes_DE; + } + } catch (ConfigurationException e) { + Logger.error("Configuration exception while getting ConfigurationProvider instance"); + e.printStackTrace(); + return guiRes_DE; + } + } + + public static String getGUIString(String code, HttpServletRequest request) { + return guiRes_DE.getString(code); } public static String getGUIString(String code) { @@ -44,16 +83,15 @@ public class LanguageHelper { } public static String getErrorString(String code, HttpServletRequest request) { - return errorRes_DE.getString(code); + return errorLanguage().getString(code); } public static String getErrorString(String code) { - return errorRes_DE.getString(code); + return errorLanguage().getString(code); } public static String getGUIString(String code, String parameter, HttpServletRequest request) { - - return MessageFormat.format(getGUIString(code, request), parameter); + return MessageFormat.format(getGUIString(code, request), parameter); } public static String getErrorString(String code, Object[] parameter, HttpServletRequest request) { -- cgit v1.2.3