add support for arb files (flutter)

Resolves #64
This commit is contained in:
Marcel Haßlinger 2021-12-07 13:22:10 +01:00
parent d66cf3595e
commit bf1338ffa0
4 changed files with 20 additions and 7 deletions

View File

@ -3,13 +3,16 @@
# easy-i18n Changelog # easy-i18n Changelog
## [Unreleased] ## [Unreleased]
### Fixed ### Added
- NullPointerException on key completion - Support for json based arb files (flutter)
- Changelog handling in release flow
### Changed ### Changed
- Updated plugin dependencies - Updated plugin dependencies
### Fixed
- NullPointerException on key completion
- Changelog handling in release flow
## [1.6.0] ## [1.6.0]
### Added ### Added
- The search function now supports full-text-search - The search function now supports full-text-search

View File

@ -29,7 +29,8 @@ import java.util.function.Consumer;
public class DataStore { public class DataStore {
private static final Set<IOStrategy> STRATEGIES = new LinkedHashSet<>(Arrays.asList( private static final Set<IOStrategy> STRATEGIES = new LinkedHashSet<>(Arrays.asList(
new JsonIOStrategy(), new ModularizedJsonIOStrategy(), new JsonIOStrategy("json"), new ModularizedJsonIOStrategy("json"),
new JsonIOStrategy("arb"), new ModularizedJsonIOStrategy("arb"),
new YamlIOStrategy("yaml"), new YamlIOStrategy("yml"), new YamlIOStrategy("yaml"), new YamlIOStrategy("yml"),
new PropertiesIOStrategy() new PropertiesIOStrategy()
)); ));

View File

@ -27,10 +27,14 @@ import java.util.function.Consumer;
* @author marhali * @author marhali
*/ */
public class JsonIOStrategy implements IOStrategy { public class JsonIOStrategy implements IOStrategy {
private static final String FILE_EXTENSION = "json";
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
private final String FILE_EXTENSION;
public JsonIOStrategy(@NotNull String fileExtension) {
this.FILE_EXTENSION = fileExtension;
}
@Override @Override
public boolean canUse(@NotNull Project project, @NotNull String localesPath, @NotNull SettingsState state) { public boolean canUse(@NotNull Project project, @NotNull String localesPath, @NotNull SettingsState state) {
VirtualFile directory = LocalFileSystem.getInstance().findFileByIoFile(new File(localesPath)); VirtualFile directory = LocalFileSystem.getInstance().findFileByIoFile(new File(localesPath));

View File

@ -33,9 +33,14 @@ import java.util.function.Consumer;
*/ */
public class ModularizedJsonIOStrategy implements IOStrategy { public class ModularizedJsonIOStrategy implements IOStrategy {
private static final String FILE_EXTENSION = "json";
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create(); private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
private final String FILE_EXTENSION;
public ModularizedJsonIOStrategy(@NotNull String fileExtension) {
this.FILE_EXTENSION = fileExtension;
}
@Override @Override
public boolean canUse(@NotNull Project project, @NotNull String localesPath, @NotNull SettingsState state) { public boolean canUse(@NotNull Project project, @NotNull String localesPath, @NotNull SettingsState state) {
VirtualFile directory = LocalFileSystem.getInstance().findFileByIoFile(new File(localesPath)); VirtualFile directory = LocalFileSystem.getInstance().findFileByIoFile(new File(localesPath));