Skip to content

Commit

Permalink
Add comments to FXML localization parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
koppor committed Aug 1, 2024
1 parent c406137 commit cd6e2c8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/test/java/org/jabref/logic/l10n/LocalizationParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -173,9 +174,11 @@ private static List<LocalizationEntry> getLocalizationParametersInJavaFile(Path

/**
* Loads the fxml file and returns all used language resources.
*
* Note: FXML prefixes localization keys with <code>%</code>.
*/
private static List<LocalizationEntry> getLanguageKeysInFxmlFile(Path path, LocalizationBundleForTest type) {
List<String> result = new ArrayList<>();
private static Collection<LocalizationEntry> getLanguageKeysInFxmlFile(Path path, LocalizationBundleForTest type) {
Collection<String> result = new ArrayList<>();

// Afterburner ViewLoader forces a controller factory, but we do not need any controller
MockedStatic<ViewLoader> viewLoader = Mockito.mockStatic(ViewLoader.class, Answers.RETURNS_DEEP_STUBS);
Expand All @@ -184,6 +187,8 @@ private static List<LocalizationEntry> 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";
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cd6e2c8

Please sign in to comment.