Test and fix for single quote escapes in I18n

This commit is contained in:
dotasek 2024-05-31 10:18:20 -04:00
parent ad31f71388
commit 684ec915fc
2 changed files with 15 additions and 1 deletions

View File

@ -125,7 +125,7 @@ public abstract class I18nBase {
if (Objects.nonNull(theMessageArguments) && theMessageArguments.length > 0) {
message = MessageFormat.format(messages.getString(theMessage).trim(), theMessageArguments);
} else {
message = messages.getString(theMessage).trim();
message = MessageFormat.format(messages.getString(theMessage).trim(), null);
}
}
return message;

View File

@ -109,6 +109,20 @@ class I18nBaseTest {
assertEquals("Documents oder Messages müssen mindestens einen Eintrag enthalten", result);
}
@Test
@DisplayName("Test double single quotes behaviour.")
void testDoubleSingleQuotes() {
I18nTestClass testClass = new I18nTestClass();
testClass.setLocale(Locale.US);
String actualMessageA = testClass.formatMessage(I18nConstants.VALUESET_EXAMPLE_SYSTEM_HINT, "Mazooma");
assertEquals("Example System 'Mazooma' specified, so Concepts and Filters can't be checked", actualMessageA);
String actualMessageB = testClass.formatMessage(I18nConstants.VALUESET_NO_SYSTEM_WARNING);
System.out.println(actualMessageB);
assertEquals("No System specified, so Concepts and Filters can't be checked", actualMessageB);
}
@Test
@DisplayName("Test German localization file contains no umlauts.")
void testThatNoOneHasMessedWithTheGermans() {