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

Add comments to FXML localization parsing #11558

Merged
merged 1 commit into from
Aug 1, 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
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