From e4669868c8c3bf0744ebb9deac1f1c3fe3664835 Mon Sep 17 00:00:00 2001 From: Bojan Suzic Date: Wed, 2 Apr 2014 15:14:49 +0200 Subject: language --- .../id/configuration/helper/LanguageHelper.java | 87 ++++++++++++---------- 1 file changed, 48 insertions(+), 39 deletions(-) (limited to 'id/ConfigWebTool/src/main/java/at') 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); + } } -- cgit v1.2.3