Search in sources :

Example 16 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.

the class LocaleServiceImplTest method get_bundle_multi.

@Test
public void get_bundle_multi() {
    final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), Locale.ENGLISH, "/phrases", "/override");
    assertNotNull(bundle);
    assertEquals(9, bundle.getKeys().size());
    assertEquals("override", bundle.localize("msg"));
}
Also used : MessageBundle(com.enonic.xp.i18n.MessageBundle) Test(org.junit.jupiter.api.Test)

Example 17 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.

the class LocaleServiceImplTest method get_UTF8_chars.

@Test
public void get_UTF8_chars() {
    final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), Locale.ENGLISH);
    assertNotNull(bundle);
    assertEquals("æøå", bundle.localize("norwegian"));
    assertEquals("ÄäÜüß", bundle.localize("german"));
    assertEquals("ŁĄŻĘĆŃŚŹ", bundle.localize("polish"));
    assertEquals("ЯБГДЖЙ", bundle.localize("russian"));
    assertEquals("アイウエオカキクケコサシスセソタチツテ", bundle.localize("japanese"));
}
Also used : MessageBundle(com.enonic.xp.i18n.MessageBundle) Test(org.junit.jupiter.api.Test)

Example 18 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.

the class LocaleServiceImplTest method get_bundle_norwegian_nn.

@Test
public void get_bundle_norwegian_nn() {
    final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), Locale.forLanguageTag("nn"), "norwegian");
    assertThat(bundle.asMap()).containsExactlyInAnyOrderEntriesOf(Map.of("a", "default", "c", "nn", "d", "no"));
}
Also used : MessageBundle(com.enonic.xp.i18n.MessageBundle) Test(org.junit.jupiter.api.Test)

Example 19 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.

the class MessageBundleImplTest method nullArguments.

@Test
public void nullArguments() {
    final Properties properties = new Properties();
    properties.put("key1", "{0}");
    MessageBundle resourceBundle = new MessageBundleImpl(properties, Locale.ROOT);
    assertEquals("{0}", resourceBundle.localize("key1", (Object[]) null));
}
Also used : MessageBundle(com.enonic.xp.i18n.MessageBundle) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Example 20 with MessageBundle

use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.

the class MessageBundleImplTest method nullArgument.

@Test
public void nullArgument() {
    final Properties properties = new Properties();
    properties.put("key1", "{0}");
    MessageBundle resourceBundle = new MessageBundleImpl(properties, Locale.ROOT);
    assertEquals("null", resourceBundle.localize("key1", (Object) null));
}
Also used : MessageBundle(com.enonic.xp.i18n.MessageBundle) Properties(java.util.Properties) Test(org.junit.jupiter.api.Test)

Aggregations

MessageBundle (com.enonic.xp.i18n.MessageBundle)26 Test (org.junit.jupiter.api.Test)22 Properties (java.util.Properties)6 Locale (java.util.Locale)3 ApplicationKey (com.enonic.xp.app.ApplicationKey)2 LocaleService (com.enonic.xp.i18n.LocaleService)2 LinkedHashSet (java.util.LinkedHashSet)2 Application (com.enonic.xp.app.Application)1 ResourceKeys (com.enonic.xp.resource.ResourceKeys)1 LocalDate (java.time.LocalDate)1 LocalTime (java.time.LocalTime)1