From cd6e2c881cf318ad8972e9d826141051c20f462f Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Thu, 1 Aug 2024 13:28:33 +0200 Subject: [PATCH] Add comments to FXML localization parsing --- .../org/jabref/logic/l10n/LocalizationParser.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java index 0fee3a33613..81dcc522cf2 100644 --- a/src/test/java/org/jabref/logic/l10n/LocalizationParser.java +++ b/src/test/java/org/jabref/logic/l10n/LocalizationParser.java @@ -10,6 +10,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.Enumeration; import java.util.HashSet; import java.util.List; @@ -173,9 +174,11 @@ private static List getLocalizationParametersInJavaFile(Path /** * Loads the fxml file and returns all used language resources. + * + * Note: FXML prefixes localization keys with %. */ - private static List getLanguageKeysInFxmlFile(Path path, LocalizationBundleForTest type) { - List result = new ArrayList<>(); + private static Collection getLanguageKeysInFxmlFile(Path path, LocalizationBundleForTest type) { + Collection result = new ArrayList<>(); // Afterburner ViewLoader forces a controller factory, but we do not need any controller MockedStatic viewLoader = Mockito.mockStatic(ViewLoader.class, Answers.RETURNS_DEEP_STUBS); @@ -184,6 +187,8 @@ private static List getLanguageKeysInFxmlFile(Path path, Loca ResourceBundle registerUsageResourceBundle = new ResourceBundle() { @Override protected Object handleGetObject(String key) { + // Here, we get the key without the percent sign at the beginning. + // All the "magic" is done at "loader.load()" called below. result.add(key); return "test"; } @@ -215,7 +220,7 @@ public boolean containsKey(String key) { return result.stream() .map(key -> new LocalizationEntry(path, key, type)) - .collect(Collectors.toList()); + .toList(); } private static void setStaticLoad(FXMLLoader loader) {