/** * Retrieve a resource bundle of the default or fail-over locale. * * @param packageName The package to search in * @return The resource bundle * @throws MissingResourceException in case both resource bundles couldn't be found. */ public static ResourceBundle getBundle( String packageName ) throws MissingResourceException { return GlobalMessageUtil.getBundle( packageName, PKG ); }
private static String calculateString( final String[] pkgNames, final Locale locale, final String key, final Object[] parameters, final Class<?> resourceClass, final String bundleName, final boolean fallbackOnRoot ) { for ( final String packageName : pkgNames ) { try { return calculateString( packageName, locale, key, parameters, resourceClass, bundleName, fallbackOnRoot ); } catch ( final MissingResourceException e ) { continue; } } return null; }
public static String getString( ResourceBundle bundle, String key, String param1, String param2 ) { try { Object[] args = { param1, param2 }; return MessageFormat.format( bundle.getString( key ), args ); } catch ( Exception e ) { return decorateMissingKey( key ); } }
public static String getErrorString( ResourceBundle bundle, String key, String param1, String param2, String param3 ) { return formatErrorMessage( key, getString( bundle, key, param1, param2, param3 ) ); }
/** * 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 ); }
final boolean logNotFoundError, final boolean fallbackOnRoot ) { final Set<Locale> activeLocales = getActiveLocales(); for ( final Locale locale : activeLocales ) { final String string = calculateString( pkgNames, locale, key, parameters, resourceClass, bundleName, fallbackOnRoot ); if ( !isMissingKey( string ) ) { return string; log.error( Const.getStackTracker( new KettleException( msg.toString() ) ) ); return decorateMissingKey( key );
@Override protected String calculateString( String packageName, String key, Object[] parameters, Class<?> resourceClass ) { if ( replaceWith != null ) { final String[] pkgNames = new String[] { replacePackage( packageName ), replaceSysBundle }; final String string = super.calculateString( pkgNames, key, parameters, resourceClass ); if ( !GlobalMessageUtil.isMissingKey( string ) ) { return string; } } final String[] pkgNames = new String[] { packageName, SYSTEM_BUNDLE_PACKAGE }; return GlobalMessageUtil.calculateString( pkgNames, key, parameters, resourceClass, BUNDLE_NAME, false ); } }
@Override protected boolean initService() { try { if ( repository.hasService( IAbsSecurityManager.class ) ) { service = (RepositorySecurityManager) repository.getService( IAbsSecurityManager.class ); String localeValue = null; try { localeValue = GlobalMessageUtil.getLocale().getDisplayName(); } catch ( MissingResourceException e ) { localeValue = GlobalMessageUtil.FAILOVER_LOCALE.toString(); } ( (IAbsSecurityManager) service ).initialize( localeValue ); } else { return false; } } catch ( Exception e ) { throw new RuntimeException( e ); } return true; }
/** * * @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; } }
public static String getErrorString( ResourceBundle bundle, String key, String param1, String param2, String param3, String param4 ) { return formatErrorMessage( key, getString( bundle, key, param1, param2, param3, param4 ) ); }
/** * Initialized the ActionPermissions UI with all the possible values from LogicalSystemRoles enum */ private void initializeLogicalSystemRolesUI() { try { Map<String, String> logicalRoles = ( (IAbsSecurityManager) service ).getAllLogicalRoles( GlobalMessageUtil.getLocale().getDisplayName() ); for ( Entry<String, String> logicalRole : logicalRoles.entrySet() ) { XulCheckbox logicalSystemRoleCheckbox; logicalSystemRoleCheckbox = (XulCheckbox) document.createElement( "checkbox" );//$NON-NLS-1$ logicalSystemRoleCheckbox.setLabel( logicalRole.getValue() ); logicalSystemRoleCheckbox.setId( logicalRole.getValue() ); logicalSystemRoleCheckbox.setCommand( "iSecurityController.updateSystemRoleActionPermission()" );//$NON-NLS-1$ logicalSystemRoleCheckbox.setFlex( 1 ); logicalSystemRoleCheckbox.setDisabled( true ); logicalSystemRolesBox.addChild( logicalSystemRoleCheckbox ); logicalSystemRoleChecboxMap.put( logicalSystemRoleCheckbox, logicalRole.getKey() ); bf.setBindingType( Binding.Type.ONE_WAY ); bf.createBinding( systemRoleListBox, "selectedIndex", logicalSystemRoleCheckbox, "disabled", buttonConverter );//$NON-NLS-1$ //$NON-NLS-2$ } } catch ( XulException xe ) { } catch ( KettleException xe ) { } }
public static ResourceBundle getBundle() { if ( RESOURCE_BUNDLE == null ) { RESOURCE_BUNDLE = GlobalMessageUtil.getBundle( BUNDLE_NAME, Messages.class ); } return RESOURCE_BUNDLE; }
public static String getErrorString( ResourceBundle bundle, String key ) { return formatErrorMessage( key, getString( bundle, key ) ); }
public static String getString( ResourceBundle bundle, String key, String param1, String param2, String param3 ) { try { Object[] args = { param1, param2, param3 }; return MessageFormat.format( bundle.getString( key ), args ); } catch ( Exception e ) { return decorateMissingKey( key ); } }
public static String calculateString( final String[] pkgNames, final String key, Object[] parameters, final Class<?> resourceClass, final String bundleName, final boolean fallbackOnRoot ) { return calculateString( pkgNames, key, parameters, resourceClass, bundleName, false, fallbackOnRoot ); }
/** * Initialized the ActionPermissions UI with all the possible values from LogicalRoles enum */ private void initializeLogicalRolesUI() { try { Map<String, String> logicalRoles = ( (IAbsSecurityManager) service ).getAllLogicalRoles( GlobalMessageUtil.getLocale().getDisplayName() ); for ( Entry<String, String> logicalRole : logicalRoles.entrySet() ) { XulCheckbox logicalRoleCheckbox; logicalRoleCheckbox = (XulCheckbox) document.createElement( "checkbox" );//$NON-NLS-1$ logicalRoleCheckbox.setLabel( logicalRole.getValue() ); logicalRoleCheckbox.setId( logicalRole.getValue() ); logicalRoleCheckbox.setCommand( "iSecurityController.updateRoleActionPermission()" );//$NON-NLS-1$ logicalRoleCheckbox.setFlex( 1 ); logicalRoleCheckbox.setDisabled( true ); logicalRolesBox.addChild( logicalRoleCheckbox ); logicalRoleChecboxMap.put( logicalRoleCheckbox, logicalRole.getKey() ); bf.setBindingType( Binding.Type.ONE_WAY ); bf.createBinding( roleListBox, "selectedIndex", logicalRoleCheckbox, "disabled", buttonConverter );//$NON-NLS-1$ //$NON-NLS-2$ } } catch ( XulException xe ) { } catch ( KettleException xe ) { } }
public static ResourceBundle getBundle( Locale locale, String packagePath, Class<?> resourceClass ) { return getBundle( locale, packagePath, resourceClass, true ); }
public static String getErrorString( ResourceBundle bundle, String key, String param1 ) { return formatErrorMessage( key, getString( bundle, key, param1 ) ); }
public static String getString( ResourceBundle bundle, String key, String param1, String param2, String param3, String param4, String param5, String param6 ) { try { Object[] args = { param1, param2, param3, param4, param5, param6 }; return MessageFormat.format( bundle.getString( key ), args ); } catch ( Exception e ) { return decorateMissingKey( key ); } }
/** * Calls {@link #calculateString(String[], String, Object[], Class, String, boolean)} with the {@code * logNotFoundError} parameter set to {@code true} to ensure proper error logging when the localized string cannot be * found. */ public static String calculateString( final String[] pkgNames, final String key, final Object[] parameters, final Class<?> resourceClass, final String bundleName ) { return calculateString( pkgNames, key, parameters, resourceClass, bundleName, false, false ); }