コード例 #1
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.hoteia.qalingo.core.i18n.message.CoreMessageSource#loadWording(java
  * .util.String, java.util.Locale)
  */
 public Map<String, String> loadWording(final String pattern, final Locale locale) {
   final Map<String, String> wordingKeyValues = new HashMap<String, String>();
   if (StringUtils.isNotEmpty(pattern)) {
     List<String> allFileNames = messageSource.getFileBasenames();
     for (Iterator<String> iterator = allFileNames.iterator(); iterator.hasNext(); ) {
       String fileName = (String) iterator.next();
       if (fileName.contains("wording")
           && (fileName.contains("common-") || fileName.contains(pattern))) {
         wordingKeyValues.putAll(messageSource.getWordingProperties(fileName, locale));
       }
     }
   }
   return wordingKeyValues;
 }
コード例 #2
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.hoteia.qalingo.core.i18n.message.CoreMessageSource#getMessage(java
  * .lang.String, java.lang.Object[], java.util.Locale)
  */
 public String getMessage(final String code, final Object args[], final Locale locale)
     throws NoSuchMessageException {
   try {
     return messageSource.getMessage(code, args, locale);
   } catch (Exception e) {
     logger.info(
         "This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
     if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) {
       return getMessage(code, args, new Locale(Constants.DEFAULT_LOCALE_CODE));
     }
   }
   return null;
 }
コード例 #3
0
 /*
  * (non-Javadoc)
  *
  * @see
  * org.hoteia.qalingo.core.i18n.message.CoreMessageSource#getMessage(java
  * .lang.String, java.lang.Object[], java.lang.String, java.util.Locale)
  */
 public String getMessage(
     final String code, final Object args[], final String defaultMessage, final Locale locale) {
   try {
     return messageSource.getMessage(code, args, defaultMessage, locale);
   } catch (Exception e) {
     if (code != null && code.contains("javax")) {
       logger.info(
           "This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
     } else {
       logger.info(
           "This message key doesn't exist: " + code + ", for this locale: " + locale.toString());
     }
     if (BooleanUtils.negate(locale.toString().equalsIgnoreCase(Constants.DEFAULT_LOCALE_CODE))) {
       return getMessage(code, args, defaultMessage, new Locale(Constants.DEFAULT_LOCALE_CODE));
     }
   }
   return null;
 }
コード例 #4
0
 public void clearCache() {
   messageSource.clearCache();
 }