PmLocalizeApi { public static String localize(PmObject pm, String key, Object... resStringArgs) { return apiHandler.localize((PmObjectBase)pm, key, resStringArgs); }  static String findLocalization(PmObject pm, String key, Object... resStringArgs); static String localize(PmObject pm, String key, Object... resStringArgs); static String localizeEnumValue(PmObject pmCtxt, Enum<?> enumValue); static String localizeBooleanValue(PmAttr<?> pmAttr, Boolean value); static String localizeOneOrMany(PmObject pm, String keybase, int number, Object... resArgs); static void setResourceStringProvider(ResourceStringProvider resourceStringProvider); static String getOutputFormatString(PmAttr<?> pmAttr);  }
@Test public void testLocalizeSimpleText() { assertEquals("Get the English resource string.", "A simple text", PmLocalizeApi.localize(pmCtxt, "pmLocalizeApiTest.simpleText")); pmCtxt.setPmLocale(Locale.GERMAN); assertEquals("Get the German resource string", "Ein einfacher Text", PmLocalizeApi.localize(pmCtxt, "pmLocalizeApiTest.simpleText")); assertEquals("A query to a non existing resource key generates a warning log and returns the key itself.", "--non-existing-resource-key--", PmLocalizeApi.localize(pmCtxt, "--non-existing-resource-key--")); }
@Test public void testLocalizeWithParameterSet() { assertEquals("Resource string parameters are embedded in the localized string.", "Item 2 of 20", PmLocalizeApi.localize(pmCtxt, "pmLocalizeApiTest.localizeWithParameterSet", 2, 20)); }
@Test public void testLocalizationOfResourceThatIsDefinedOnlyForDefaultLanguage() { assertEquals("Get a resource that is defined only in English (default language) for English locale.", "Default language text", PmLocalizeApi.localize(pmCtxt, "pmLocalizeApiTest.simpleTextDefinedOnlyForDefaultLanguage")); pmCtxt.setPmLocale(Locale.GERMAN); assertEquals("Get a resource that is defined only in English (default language) for German locale. - Provides the English default text.", "Default language text", PmLocalizeApi.localize(pmCtxt, "pmLocalizeApiTest.simpleTextDefinedOnlyForDefaultLanguage")); }