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 );
  }
@Test
  public void calculateString() {

    // "fr", "FR"
    Assert.assertEquals( "Une certaine valeur foo", GlobalMessageUtil.calculateString(
      GlobalMessages.SYSTEM_BUNDLE_PACKAGE, Locale.FRANCE, "someKey", new String[] { "foo" }, GlobalMessages.PKG,
      GlobalMessages.BUNDLE_NAME ) );

    // "fr" - should fall back on default bundle
    String str = GlobalMessageUtil.calculateString( GlobalMessages.SYSTEM_BUNDLE_PACKAGE,
      Locale.FRENCH, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME );
    Assert.assertEquals( "Some Value foo", str );

    // "jp"
    Assert.assertEquals( "何らかの値 foo", GlobalMessageUtil.calculateString( GlobalMessages.SYSTEM_BUNDLE_PACKAGE,
      Locale.JAPANESE, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME ) );

    // "jp", "JP" - should fall back on "jp"
    str = GlobalMessageUtil.calculateString( GlobalMessages.SYSTEM_BUNDLE_PACKAGE, Locale.JAPAN, "someKey", new String[]
      { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME );
    Assert.assertEquals( "何らかの値 foo", str );

    // try with multiple packages
    // make sure the selected language is used correctly
    LanguageChoice.getInstance().setDefaultLocale( Locale.FRANCE ); // "fr", "FR"
    Assert.assertEquals( "Une certaine valeur foo", GlobalMessageUtil.calculateString( new String[] { GlobalMessages
      .SYSTEM_BUNDLE_PACKAGE }, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME ) );

    LanguageChoice.getInstance().setDefaultLocale( Locale.FRENCH ); // "fr" - fall back on "default" messages.properties
    Assert.assertEquals( "Some Value foo", GlobalMessageUtil.calculateString( new String[] { GlobalMessages
      .SYSTEM_BUNDLE_PACKAGE }, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME ) );

    LanguageChoice.getInstance().setDefaultLocale( Locale.FRENCH ); // "fr" - fall back on foo/messages_fr.properties
    Assert.assertEquals( "Une certaine valeur foo", GlobalMessageUtil.calculateString( new String[] { GlobalMessages
        .SYSTEM_BUNDLE_PACKAGE, "org.pentaho.di.foo" }, "someKey", new String[] { "foo" }, GlobalMessages.PKG,
      GlobalMessages.BUNDLE_NAME ) );

    LanguageChoice.getInstance().setDefaultLocale( Locale.JAPANESE ); // "jp"
    Assert.assertEquals( "何らかの値 foo", GlobalMessageUtil.calculateString( new String[] { GlobalMessages
      .SYSTEM_BUNDLE_PACKAGE }, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME ) );

    LanguageChoice.getInstance().setDefaultLocale( Locale.JAPAN ); // "jp", "JP" - fall back on "jp"
    Assert.assertEquals( "何らかの値 foo", GlobalMessageUtil.calculateString( new String[] { GlobalMessages
      .SYSTEM_BUNDLE_PACKAGE }, "someKey", new String[] { "foo" }, GlobalMessages.PKG, GlobalMessages.BUNDLE_NAME ) );
  }