Merge pull request #76 from dBucik/fix_locales

fix: 🐛 Fix fallbacking of locale to the code to prevent errors
pull/1580/head
Dominik František Bučík 2021-12-02 16:27:24 +01:00 committed by GitHub
commit dbc0710142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -58,6 +58,8 @@ public class JsonMessageSource extends AbstractMessageSource {
this.config = config;
}
@Override
protected MessageFormat resolveCode(String code, Locale locale) {
@ -73,7 +75,7 @@ public class JsonMessageSource extends AbstractMessageSource {
if (value == null) {
// if it's still null, return null
return null;
return new MessageFormat(code, locale);
} else {
// otherwise format the message
return new MessageFormat(value, locale);

View File

@ -43,7 +43,8 @@ public class TestJsonMessageSource {
@Test
public void verifyWhenLocaleDoesNotExist_cannotResolveCode() {
String code = "test";
MessageFormat mf = jsonMessageSource.resolveCode("test", localeThatDoesNotHaveAFile);
assertNull(mf);
assertEquals(code, mf.toPattern());
}
}