Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refine TODO #11820

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,22 @@ void findObsoleteLocalizationKeys() throws IOException {

@Test
void localizationParameterMustIncludeAString() throws IOException {
// Must start or end with "
// Localization.lang("test"), Localization.lang("test" + var), Localization.lang(var + "test")
// TODO: Localization.lang(var1 + "test" + var2) not covered
// Localization.lang("Problem downloading from %1", address)
// Must start with "
// - Localization.lang("test")
// - Localization.lang("test %1", var)
// - Localization.lang("Problem downloading from %1", address)
// - Localization.lang("test %1 %2", var1, var2)
Set<LocalizationEntry> keys = LocalizationParser.findLocalizationParametersStringsInJavaFiles(LocalizationBundleForTest.LANG);
for (LocalizationEntry e : keys) {
assertTrue(e.getKey().startsWith("\"") || e.getKey().endsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey());
// TODO: Forbidden Localization.lang("test" + var2) not covered by the test
// In case this kind of code is found, an error should be reported
// JabRef's infrastructure only supports Localization.lang("Some Message"); and not something else.
assertTrue(e.getKey().startsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey());
}

keys = LocalizationParser.findLocalizationParametersStringsInJavaFiles(LocalizationBundleForTest.MENU);
for (LocalizationEntry e : keys) {
assertTrue(e.getKey().startsWith("\"") || e.getKey().endsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey());
assertTrue(e.getKey().startsWith("\""), "Illegal localization parameter found. Must include a String with potential concatenation or replacement parameters. Illegal parameter: Localization.lang(" + e.getKey());
}
}

Expand Down