diff --git a/lib/src/etc/controllers/config_file.dart b/lib/src/etc/controllers/config_file.dart index d586919..a7ec405 100644 --- a/lib/src/etc/controllers/config_file.dart +++ b/lib/src/etc/controllers/config_file.dart @@ -126,7 +126,7 @@ abstract class ConfigFile { sourceFile: sourceLocalizationFilePath, outputDir: outputDir, langs: targetLangsList, - languageLocalizationMaxDelay: languageLocalizationMaxDelay ?? 450, + languageLocalizationMaxDelay: languageLocalizationMaxDelay, ).toMap(); } diff --git a/lib/src/etc/controllers/json.dart b/lib/src/etc/controllers/json.dart index 344e4b8..259a65b 100644 --- a/lib/src/etc/controllers/json.dart +++ b/lib/src/etc/controllers/json.dart @@ -2,6 +2,7 @@ import 'dart:convert'; import 'dart:io'; import 'package:langsync/src/etc/controllers/config_file.dart'; +import 'package:langsync/src/etc/extensions.dart'; class JsonController extends ConfigFile { @override @@ -19,7 +20,7 @@ class JsonController extends ConfigFile { @override Future writeNewConfig(Map config) { return super.writeToConfigFile( - jsonEncode({'langsync': config}), + {'langsync': config}.toPrettyJson(), ); } } diff --git a/lib/src/etc/controllers/yaml.dart b/lib/src/etc/controllers/yaml.dart index 1d1d40d..8c6d6d5 100644 --- a/lib/src/etc/controllers/yaml.dart +++ b/lib/src/etc/controllers/yaml.dart @@ -16,7 +16,14 @@ class YamlController extends ConfigFile { ); } - Future iterateAndWriteToConfigFile( + @override + Future writeNewConfig(Map config) async { + await super.writeToConfigFile('langsync:\n'); + + await _iterateAndWriteToConfigFile(config); + } + + Future _iterateAndWriteToConfigFile( Map config, ) async { super.iterateOverConfig( @@ -34,11 +41,4 @@ class YamlController extends ConfigFile { }, ); } - - @override - Future writeNewConfig(Map config) async { - await super.writeToConfigFile('langsync:\n'); - - await iterateAndWriteToConfigFile(config); - } } diff --git a/lib/src/etc/models/config.dart b/lib/src/etc/models/config.dart index c5df905..8b9659f 100644 --- a/lib/src/etc/models/config.dart +++ b/lib/src/etc/models/config.dart @@ -6,7 +6,7 @@ class LangSyncConfig extends Equatable { required this.sourceFile, required this.outputDir, required this.langs, - required this.languageLocalizationMaxDelay, + this.languageLocalizationMaxDelay, }); factory LangSyncConfig.fromMap(Map map) { @@ -21,14 +21,14 @@ class LangSyncConfig extends Equatable { outputDir: langsyncMapField['output'] as String, langs: target, languageLocalizationMaxDelay: - langsyncMapField['languageLocalizationMaxDelay'] as int, + (langsyncMapField['languageLocalizationMaxDelay'] as int?) ?? 450, ); } final String sourceFile; final String outputDir; final Iterable langs; - final int languageLocalizationMaxDelay; + final int? languageLocalizationMaxDelay; List get langsJsonFiles => langs.map((e) => '$e.json').toList(); @@ -45,7 +45,7 @@ class LangSyncConfig extends Equatable { 'source': sourceFile, 'output': outputDir, 'target': langs.toList(), - 'languageLocalizationMaxDelay': languageLocalizationMaxDelay, + 'languageLocalizationMaxDelay': languageLocalizationMaxDelay ?? 450, }; } }