From 8e4179983b3f7774e96a7f1c515d715f25b9ea92 Mon Sep 17 00:00:00 2001 From: marhali Date: Tue, 11 Jan 2022 14:22:32 +0100 Subject: [PATCH] base file pattern matcher on unix/window style wildcards --- CHANGELOG.md | 4 ++++ .../java/de/marhali/easyi18n/dialog/SettingsDialog.java | 1 + src/main/java/de/marhali/easyi18n/io/IOStrategy.java | 6 ++++-- src/main/java/de/marhali/easyi18n/model/SettingsState.java | 2 +- src/main/resources/messages.properties | 6 ++++-- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc90b8a..a861de7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,15 @@ # easy-i18n Changelog ## [Unreleased] +### BREAKING CHANGES +- Translation file pattern matcher needs to be updated to \*.* or equivalent wildcard rule + ### Added - Full keyboard shortcut support inside tool-window - Support for dots within key nodes in YAML files ### Changed +- Translation file pattern uses wildcard matcher instead of regex - Improve exception handling on IO operations - Update Qodana to latest version - Allow tool-window rendering in dumb mode diff --git a/src/main/java/de/marhali/easyi18n/dialog/SettingsDialog.java b/src/main/java/de/marhali/easyi18n/dialog/SettingsDialog.java index e4e4c3c..da916b6 100644 --- a/src/main/java/de/marhali/easyi18n/dialog/SettingsDialog.java +++ b/src/main/java/de/marhali/easyi18n/dialog/SettingsDialog.java @@ -74,6 +74,7 @@ public class SettingsDialog { /* file pattern */ JBLabel filePatternLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern")); filePatternText = new JBTextField(state.getFilePattern()); + filePatternText.setToolTipText(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern-tooltip")); rootPanel.add(filePatternLabel); rootPanel.add(filePatternText); diff --git a/src/main/java/de/marhali/easyi18n/io/IOStrategy.java b/src/main/java/de/marhali/easyi18n/io/IOStrategy.java index 7a9fdc9..74e9975 100644 --- a/src/main/java/de/marhali/easyi18n/io/IOStrategy.java +++ b/src/main/java/de/marhali/easyi18n/io/IOStrategy.java @@ -1,11 +1,12 @@ package de.marhali.easyi18n.io; import com.intellij.openapi.project.Project; - import com.intellij.openapi.vfs.VirtualFile; + import de.marhali.easyi18n.model.SettingsState; import de.marhali.easyi18n.model.TranslationData; +import org.apache.commons.io.FilenameUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -57,6 +58,7 @@ public interface IOStrategy { * @return true if file matches pattern */ default boolean isFileRelevant(@NotNull SettingsState state, @NotNull VirtualFile file) { - return file.getName().matches(state.getFilePattern()); + System.out.println(file.getName() + " " + FilenameUtils.wildcardMatch(file.getName(), state.getFilePattern())); + return FilenameUtils.wildcardMatch(file.getName(), state.getFilePattern()); } } diff --git a/src/main/java/de/marhali/easyi18n/model/SettingsState.java b/src/main/java/de/marhali/easyi18n/model/SettingsState.java index 5c322eb..8289fad 100644 --- a/src/main/java/de/marhali/easyi18n/model/SettingsState.java +++ b/src/main/java/de/marhali/easyi18n/model/SettingsState.java @@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable; public class SettingsState { public static final String DEFAULT_PREVIEW_LOCALE = "en"; - public static final String DEFAULT_FILE_PATTERN = ".*"; + public static final String DEFAULT_FILE_PATTERN = "*.*"; public static final String DEFAULT_PATH_PREFIX = ""; public static final boolean DEFAULT_SORT_KEYS = true; public static final boolean DEFAULT_NESTED_KEYS = true; diff --git a/src/main/resources/messages.properties b/src/main/resources/messages.properties index eea38f5..790d8f4 100644 --- a/src/main/resources/messages.properties +++ b/src/main/resources/messages.properties @@ -5,6 +5,7 @@ view.table.title=TableView view.empty=No translations found. Click on settings to specify a locales directory or reload action.add=Add Translation action.edit=Edit Translation +action.toggle-missing=Toggle missing translations action.reload=Reload From Disk action.settings=Settings action.search=Search... @@ -13,10 +14,11 @@ translation.key=Key translation.locales=Locales settings.path.title=Locales Directory settings.path.text=Locales directory -settings.path.file-pattern=Translation file pattern +settings.path.file-pattern=Translation file wildcard matcher +settings.path.file-pattern-tooltip=Defines a wildcard matcher to filter relevant translation files. For example *.json, *.???. settings.path.prefix=Path prefix settings.preview=Preview locale settings.keys.sort=Sort translation keys alphabetically settings.keys.nested=Nest translation keys if possible settings.editor.assistance=I18n key completion, annotation and reference inside editor -error.io=Could not process file {0} with {1}. Unwanted files can be ignored via Translation file pattern option. \ No newline at end of file +error.io=Could not process file {0} with {1}. Unwanted files can be ignored via Translation file wildcard matcher option. \ No newline at end of file