base file pattern matcher on unix/window style wildcards

This commit is contained in:
marhali 2022-01-11 14:22:32 +01:00
parent 613d0c5bc9
commit 8e4179983b
5 changed files with 14 additions and 5 deletions

View File

@ -3,11 +3,15 @@
# easy-i18n Changelog # easy-i18n Changelog
## [Unreleased] ## [Unreleased]
### BREAKING CHANGES
- Translation file pattern matcher needs to be updated to <kbd>\*.*</kbd> or equivalent wildcard rule
### Added ### Added
- Full keyboard shortcut support inside tool-window - Full keyboard shortcut support inside tool-window
- Support for dots within key nodes in YAML files - Support for dots within key nodes in YAML files
### Changed ### Changed
- Translation file pattern uses wildcard matcher instead of regex
- Improve exception handling on IO operations - Improve exception handling on IO operations
- Update Qodana to latest version - Update Qodana to latest version
- Allow tool-window rendering in dumb mode - Allow tool-window rendering in dumb mode

View File

@ -74,6 +74,7 @@ public class SettingsDialog {
/* file pattern */ /* file pattern */
JBLabel filePatternLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern")); JBLabel filePatternLabel = new JBLabel(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern"));
filePatternText = new JBTextField(state.getFilePattern()); filePatternText = new JBTextField(state.getFilePattern());
filePatternText.setToolTipText(ResourceBundle.getBundle("messages").getString("settings.path.file-pattern-tooltip"));
rootPanel.add(filePatternLabel); rootPanel.add(filePatternLabel);
rootPanel.add(filePatternText); rootPanel.add(filePatternText);

View File

@ -1,11 +1,12 @@
package de.marhali.easyi18n.io; package de.marhali.easyi18n.io;
import com.intellij.openapi.project.Project; import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFile;
import de.marhali.easyi18n.model.SettingsState; import de.marhali.easyi18n.model.SettingsState;
import de.marhali.easyi18n.model.TranslationData; import de.marhali.easyi18n.model.TranslationData;
import org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -57,6 +58,7 @@ public interface IOStrategy {
* @return true if file matches pattern * @return true if file matches pattern
*/ */
default boolean isFileRelevant(@NotNull SettingsState state, @NotNull VirtualFile file) { 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());
} }
} }

View File

@ -10,7 +10,7 @@ import org.jetbrains.annotations.Nullable;
public class SettingsState { public class SettingsState {
public static final String DEFAULT_PREVIEW_LOCALE = "en"; 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 String DEFAULT_PATH_PREFIX = "";
public static final boolean DEFAULT_SORT_KEYS = true; public static final boolean DEFAULT_SORT_KEYS = true;
public static final boolean DEFAULT_NESTED_KEYS = true; public static final boolean DEFAULT_NESTED_KEYS = true;

View File

@ -5,6 +5,7 @@ view.table.title=TableView
view.empty=No translations found. Click on settings to specify a locales directory or reload view.empty=No translations found. Click on settings to specify a locales directory or reload
action.add=Add Translation action.add=Add Translation
action.edit=Edit Translation action.edit=Edit Translation
action.toggle-missing=Toggle missing translations
action.reload=Reload From Disk action.reload=Reload From Disk
action.settings=Settings action.settings=Settings
action.search=Search... action.search=Search...
@ -13,10 +14,11 @@ translation.key=Key
translation.locales=Locales translation.locales=Locales
settings.path.title=Locales Directory settings.path.title=Locales Directory
settings.path.text=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.path.prefix=Path prefix
settings.preview=Preview locale settings.preview=Preview locale
settings.keys.sort=Sort translation keys alphabetically settings.keys.sort=Sort translation keys alphabetically
settings.keys.nested=Nest translation keys if possible settings.keys.nested=Nest translation keys if possible
settings.editor.assistance=I18n key completion, annotation and reference inside editor 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. error.io=Could not process file {0} with {1}. Unwanted files can be ignored via Translation file wildcard matcher option.