diff options
author | Bojan Suzic <bojan.suzic@iaik.tugraz.at> | 2014-04-02 15:14:49 +0200 |
---|---|---|
committer | Bojan Suzic <bojan.suzic@iaik.tugraz.at> | 2014-04-02 15:14:49 +0200 |
commit | e4669868c8c3bf0744ebb9deac1f1c3fe3664835 (patch) | |
tree | bef58125cd27e5c7796ca27122a28b6608b7b3a9 /id/ConfigWebTool/src/main/java/at | |
parent | 4b890232cc2ef904ede71663abb4fb5f3d8be7e8 (diff) | |
download | moa-id-spss-e4669868c8c3bf0744ebb9deac1f1c3fe3664835.tar.gz moa-id-spss-e4669868c8c3bf0744ebb9deac1f1c3fe3664835.tar.bz2 moa-id-spss-e4669868c8c3bf0744ebb9deac1f1c3fe3664835.zip |
language
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at')
-rw-r--r-- | id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/helper/LanguageHelper.java | 87 |
1 files changed, 48 insertions, 39 deletions
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 73b2708ae..b207e7118 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 @@ -27,81 +27,90 @@ 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 javax.servlet.http.HttpServletRequest; import java.text.MessageFormat; import java.util.Locale; import java.util.ResourceBundle; -import javax.servlet.http.HttpServletRequest; - public class LanguageHelper { - private static ResourceBundle errorRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); - private static ResourceBundle guiRes_DE = ResourceBundle.getBundle("applicationResources", Locale.GERMAN); + private static ResourceBundle errorRes_DE = ResourceBundle.getBundle("applicationResources_de", Locale.GERMAN); + private static ResourceBundle guiRes_DE = ResourceBundle.getBundle("applicationResources_de", Locale.GERMAN); 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() { + private static String errorLanguage(String code) { Logger.setHierarchy("moa.id.configuration"); try { ConfigurationProvider configurationProvider = ConfigurationProvider.getInstance(); if (configurationProvider.getDefaultLanguage().equals("en")) { - return errorRes_EN; + Logger.trace("Returning EN error message"); + return errorRes_EN.getString(code); } else { - return errorRes_DE; + Logger.trace("Returning DE error message"); } } catch (ConfigurationException e) { Logger.error("Configuration exception while getting ConfigurationProvider instance"); e.printStackTrace(); - return errorRes_DE; + return errorRes_DE.getString(code); + } catch (Exception ex) { + Logger.error("General exception while returning translated message"); + return errorRes_DE.getString(code); } + return errorRes_DE.getString(code); } - private static ResourceBundle guiLanguage() { + private static String guiLanguage(String code) { Logger.setHierarchy("moa.id.configuration"); try { ConfigurationProvider configurationProvider = ConfigurationProvider.getInstance(); if (configurationProvider.getDefaultLanguage().equals("en")) { - return guiRes_EN; + Logger.trace("Returning EN gui message: " + guiRes_EN.getString(code)); + return guiRes_EN.getString(code); } else { - return guiRes_DE; + Logger.trace("Returning DE gui message: " + guiRes_DE.getString(code) + " /en>" + guiRes_EN.getString(code)); + return guiRes_DE.getString(code); } } catch (ConfigurationException e) { Logger.error("Configuration exception while getting ConfigurationProvider instance"); e.printStackTrace(); - return guiRes_DE; + return guiRes_DE.getString(code); + } catch (Exception ex) { + Logger.error("General exception while returning translated message"); + return guiRes_DE.getString(code); } } public static String getGUIString(String code, HttpServletRequest request) { - return guiRes_DE.getString(code); - } - - public static String getGUIString(String code) { - return guiRes_DE.getString(code); - } - - public static String getErrorString(String code, HttpServletRequest request) { - return errorLanguage().getString(code); - } - - public static String getErrorString(String code) { - return errorLanguage().getString(code); - } - - public static String getGUIString(String code, String parameter, HttpServletRequest request) { + return guiLanguage(code); + } + + public static String getGUIString(String code) { + return guiLanguage(code); + } + + public static String getErrorString(String code, HttpServletRequest request) { + return errorLanguage(code); + } + + public static String getErrorString(String code) { + return errorLanguage(code); + } + + public static String getGUIString(String code, String parameter, HttpServletRequest request) { + return MessageFormat.format(getGUIString(code, request), parameter); + } + + public static String getErrorString(String code, Object[] parameter, HttpServletRequest request) { + return MessageFormat.format(getGUIString(code, request), parameter); - } - - public static String getErrorString(String code, Object[] parameter, HttpServletRequest request) { - - return MessageFormat.format(getGUIString(code, request), parameter); - } - - public static String getErrorString(String code, Object[] parameter) { - - return MessageFormat.format(getGUIString(code), parameter); - } + } + + public static String getErrorString(String code, Object[] parameter) { + + return MessageFormat.format(getGUIString(code), parameter); + } } |