/** * Retrieve a resource bundle of the default or fail-over locales. * * @param packagePath The package to search in * @param resourceClass the class to use to resolve the bundle * @return The resource bundle * @throws MissingResourceException in case both resource bundles couldn't be found. */ public static ResourceBundle getBundle( final String packagePath, final Class<?> resourceClass ) throws MissingResourceException { final Set<Locale> activeLocales = getActiveLocales(); for ( final Locale locale : activeLocales ) { try { return getBundle( locale, packagePath, resourceClass ); } catch ( MissingResourceException e ) { final StringBuilder msg = new StringBuilder(); msg.append( "Unable to find properties file for package '" ).append( packagePath ).append( "' and class '" ) .append( resourceClass.getName() ).append( "' in the available locales: " ).append( locale ); // nothing to do, an exception will be thrown if no bundle is found log.warn( msg.toString() ); } } final StringBuilder msg = new StringBuilder(); msg.append( "Unable to find properties file for package '" ).append( packagePath ).append( "' and class '" ) .append( resourceClass.getName() ).append( "' in the available locales: " ).append( Arrays.asList( activeLocales ) ); throw new MissingResourceException( msg.toString(), resourceClass.getName(), packagePath ); }
/** * * @param input * @param localizedMap * @return */ protected String getAlternativeTranslation( String input, Map<String, String> localizedMap ) { if ( Utils.isEmpty( input ) ) { return null; } if ( input.startsWith( "i18n" ) ) { return getCodedTranslation( input ); } else { for ( final Locale locale : GlobalMessageUtil.getActiveLocales() ) { String alt = localizedMap.get( locale.toString().toLowerCase() ); if ( !Utils.isEmpty( alt ) ) { return alt; } } // Nothing found? // Return the original! // return input; } }
final boolean logNotFoundError, final boolean fallbackOnRoot ) { final Set<Locale> activeLocales = getActiveLocales(); for ( final Locale locale : activeLocales ) { final String string =