Skip to content

Commit dba8db5

Browse files
Patrick ScheibeLinusDietz
Patrick Scheibe
authored andcommitted
Fix test for quoted lang messages (#3424)
1 parent bc074eb commit dba8db5

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

src/main/java/org/jabref/gui/EntryTypeDialog.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private JPanel createIdFetcherPanel() {
216216
constraints.fill = GridBagConstraints.NONE;
217217
jPanel.add(generateButton, constraints);
218218

219-
jPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("ID-based_entry_generator")));
219+
jPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), Localization.lang("ID-based entry generator")));
220220

221221
SwingUtilities.invokeLater(() -> idTextField.requestFocus());
222222

src/main/java/org/jabref/gui/preftabs/ImportSettingsTab.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ public ImportSettingsTab(JabRefPreferences prefs) {
4646

4747
setLayout(new BorderLayout());
4848
FormLayout layout = new FormLayout("1dlu, 8dlu, left:pref, 4dlu, fill:3dlu");
49-
radioButtonNoMeta = new JRadioButton(Localization.lang("Create_blank_entry_linking_the_PDF"));
50-
radioButtonXmp = new JRadioButton(Localization.lang("Create_entry_based_on_XMP-metadata"));
51-
radioButtonPDFcontent = new JRadioButton(Localization.lang("Create_entry_based_on_content"));
52-
radioButtononlyAttachPDF = new JRadioButton(Localization.lang("Only_attach_PDF"));
49+
radioButtonNoMeta = new JRadioButton(Localization.lang("Create blank entry linking the PDF"));
50+
radioButtonXmp = new JRadioButton(Localization.lang("Create entry based on XMP-metadata"));
51+
radioButtonPDFcontent = new JRadioButton(Localization.lang("Create entry based on content"));
52+
radioButtononlyAttachPDF = new JRadioButton(Localization.lang("Only attach PDF"));
5353
ButtonGroup bg = new ButtonGroup();
5454
bg.add(radioButtonNoMeta);
5555
bg.add(radioButtonXmp);

src/test/java/org/jabref/logic/l10n/LocalizationConsistencyTest.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ public void keyValueShouldBeEqualForEnglishPropertiesMessages() {
116116
}
117117
}
118118

119+
@Test
120+
public void languageKeysShouldNotBeQuotedInFiles() throws IOException {
121+
final List<LocalizationEntry> quotedEntries = LocalizationParser
122+
.findLocalizationParametersStringsInJavaFiles(LocalizationBundleForTest.LANG)
123+
.stream()
124+
.filter(key -> key.getKey().contains("_") && key.getKey().equals(new LocalizationKey(key.getKey()).getPropertiesKey()))
125+
.collect(Collectors.toList());
126+
Assert.assertEquals(
127+
"Language keys must not be used quoted in code! Use \"This is a message\" instead of \"This_is_a_message\".\n" +
128+
"Please correct the following entries:\n" +
129+
quotedEntries
130+
.stream()
131+
.map(key -> String.format("\n%s (%s)\n", key.getKey(), key.getPath()))
132+
.collect(Collectors.toList())
133+
,
134+
Collections.EMPTY_LIST, quotedEntries);
135+
}
136+
119137
@Test
120138
public void findMissingLocalizationKeys() throws IOException {
121139
List<LocalizationEntry> missingKeys = LocalizationParser.find(LocalizationBundleForTest.LANG).stream().sorted()
@@ -125,7 +143,7 @@ public void findMissingLocalizationKeys() throws IOException {
125143
"1. PASTE THESE INTO THE ENGLISH LANGUAGE FILE\n" +
126144
"2. EXECUTE: gradlew localizationUpdate\n" +
127145
missingKeys.parallelStream()
128-
.map(key -> String.format("%s=%s", key.getKey(), key.getKey()))
146+
.map(key -> String.format("\n%s=%s\n", key.getKey(), key.getKey()))
129147
.collect(Collectors.toList()),
130148
Collections.<LocalizationEntry>emptyList(), missingKeys);
131149
}

0 commit comments

Comments
 (0)