use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class MessageBundleImplTest method testEmptyValue.
@Test
public void testEmptyValue() {
MessageBundle resourceBundle = createDefault();
assertNull(resourceBundle.localize("key6"));
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class MessageBundleImplTest method testParameterizedPhraseMissingParameter.
@Test
public void testParameterizedPhraseMissingParameter() {
MessageBundle resourceBundle = createDefault();
Object[] testArgs = { "myValue1" };
String resolvedPhrase = resourceBundle.localize("key5", testArgs);
assertEquals("value is here myValue1 and there {1}", resolvedPhrase);
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class MessageBundleImplTest method testParameterizedPhrase.
@Test
public void testParameterizedPhrase() {
MessageBundle resourceBundle = createDefault();
Object[] testArgs = { "myValue1" };
String resolvedPhrase = resourceBundle.localize("key4", testArgs);
assertEquals("value is here myValue1", resolvedPhrase);
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocalizeFunction method execute.
@Override
public Object execute(final ViewFunctionParams params) {
final LocalizeParams localizeParams = new LocalizeParams(PortalRequestAccessor.get()).setAsMap(params.getArgs());
final MessageBundle bundle = this.localeService.getBundle(localizeParams.getApplicationKey(), localizeParams.getLocale());
if (bundle == null) {
return MessageFormat.format(NO_MATCHING_BUNDLE, localizeParams.getApplicationKey());
}
final String localizedMessage = bundle.localize(localizeParams.getKey(), localizeParams.getParams());
return localizedMessage != null ? localizedMessage : NOT_TRANSLATED_MESSAGE;
}
use of com.enonic.xp.i18n.MessageBundle in project xp by enonic.
the class LocaleServiceImplTest method get_bundle_with_country.
@Test
public void get_bundle_with_country() {
final MessageBundle bundle = localeService.getBundle(ApplicationKey.from("myapplication"), Locale.US);
assertNotNull(bundle);
assertEquals(9, bundle.getKeys().size());
assertEquals("en_US", bundle.localize("msg"));
}
Aggregations