Skip to content

Commit

Permalink
[ Edit ] minor edits, made the langsync.json content prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
anasfik committed Oct 17, 2023
1 parent 616b8e8 commit d8a1405
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/src/etc/controllers/config_file.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ abstract class ConfigFile {
sourceFile: sourceLocalizationFilePath,
outputDir: outputDir,
langs: targetLangsList,
languageLocalizationMaxDelay: languageLocalizationMaxDelay ?? 450,
languageLocalizationMaxDelay: languageLocalizationMaxDelay,
).toMap();
}

Expand Down
3 changes: 2 additions & 1 deletion lib/src/etc/controllers/json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -19,7 +20,7 @@ class JsonController extends ConfigFile {
@override
Future<void> writeNewConfig(Map<String, dynamic> config) {
return super.writeToConfigFile(
jsonEncode({'langsync': config}),
{'langsync': config}.toPrettyJson(),
);
}
}
16 changes: 8 additions & 8 deletions lib/src/etc/controllers/yaml.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ class YamlController extends ConfigFile {
);
}

Future<void> iterateAndWriteToConfigFile(
@override
Future<void> writeNewConfig(Map<String, dynamic> config) async {
await super.writeToConfigFile('langsync:\n');

await _iterateAndWriteToConfigFile(config);
}

Future<void> _iterateAndWriteToConfigFile(
Map<dynamic, dynamic> config,
) async {
super.iterateOverConfig(
Expand All @@ -34,11 +41,4 @@ class YamlController extends ConfigFile {
},
);
}

@override
Future<void> writeNewConfig(Map<String, dynamic> config) async {
await super.writeToConfigFile('langsync:\n');

await iterateAndWriteToConfigFile(config);
}
}
8 changes: 4 additions & 4 deletions lib/src/etc/models/config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<dynamic, dynamic> map) {
Expand All @@ -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<String> langs;
final int languageLocalizationMaxDelay;
final int? languageLocalizationMaxDelay;

List<String> get langsJsonFiles => langs.map((e) => '$e.json').toList();

Expand All @@ -45,7 +45,7 @@ class LangSyncConfig extends Equatable {
'source': sourceFile,
'output': outputDir,
'target': langs.toList(),
'languageLocalizationMaxDelay': languageLocalizationMaxDelay,
'languageLocalizationMaxDelay': languageLocalizationMaxDelay ?? 450,
};
}
}

0 comments on commit d8a1405

Please sign in to comment.