/** * The message source will search for "messages*.properties" files first in the WEB-INF folder, * then anywhere within the classpath. This means that entries in the former will take * precedence over similar entries found in the classpath. Thus, entries placed in any * "message*.properties" files under the WEB-INF folder will override entries declared * elsewhere. */ private ClasspathMessageSource() { super(); setBasenames("WEB-INF/messages", "classpath*:/**/messages"); setDefaultEncoding(StandardCharsets.UTF_8.name()); Localizer.registerMessageSource((id, locale, args) -> { return getMessage(id, args, locale); }); }
@Test public void testBundle() { Localizer.registerMessageSource(new BundleMessageSource()); Locale locale1 = new Locale("en"); Locale locale2 = new Locale("fr"); assertEquals("keyboard", StrUtil.getLabel("message.test1", locale1)); assertEquals("clavier", StrUtil.getLabel("message.test1", locale2)); }