DefaultMessages extends AbstractMessages implements Messages { @Override public String getMessage(String key, MessageParams params, Locale locale) { return getTemplate(key, locale).execute(params.toMap()); } DefaultMessages(String baseName);  DefaultMessages(String baseName, Charset charset); String getBaseName(); Charset getCharset(); @Override String getMessage(String key, MessageParams params, Locale locale); @Override Iterable<String> keys(Locale locale); @Override Iterable<String> keys(); @Override Iterable<Entry<String, String>> entries(Locale locale); @Override String getMessageTemplate(String key, Locale locale); @Override String toString();  }
@Test public void should_translate_simple() throws Exception { DefaultMessages m = new DefaultMessages("restx.i18n.test"); assertThat(m.getMessage("key1", Locale.ENGLISH)).isEqualTo("Hello!"); assertThat(m.getMessage("key1", Locale.FRENCH)).isEqualTo("Bonjour !"); }
@Test public void should_translate_with_params() throws Exception { DefaultMessages m = new DefaultMessages("restx.i18n.test"); assertThat(m.getMessage("key2", MessageParams.of("who", "World"), Locale.ENGLISH)).isEqualTo("Hello World!"); assertThat(m.getMessage("key2", MessageParams.of("who", "World"), Locale.FRENCH)).isEqualTo("Bonjour World !"); }