From d429cd4cb71e834d86fabdf3a1e3d15c1a5685d0 Mon Sep 17 00:00:00 2001 From: Anas Fikhi Date: Wed, 6 Dec 2023 12:53:40 +0100 Subject: [PATCH] [ Edit ] edited the config file model class and minor changes --- .../commands/start_command/start_command.dart | 2 +- lib/src/etc/extensions.dart | 4 ++++ lib/src/etc/models/api_key_res.dart | 1 + lib/src/etc/models/config.dart | 18 ++++++++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/src/commands/start_command/start_command.dart b/lib/src/commands/start_command/start_command.dart index 8895e65..34f37e9 100644 --- a/lib/src/commands/start_command/start_command.dart +++ b/lib/src/commands/start_command/start_command.dart @@ -140,7 +140,7 @@ class StartCommand extends Command { logger ..info('\n') ..info( - 'Generating localization files: ${asConfig.langsJsonFiles.join(", ")}.', + 'Generating localization files: ${asConfig.langsJsonFiles().join(", ")}.', ); final outputList = diff --git a/lib/src/etc/extensions.dart b/lib/src/etc/extensions.dart index 6d09485..a8c98ea 100644 --- a/lib/src/etc/extensions.dart +++ b/lib/src/etc/extensions.dart @@ -117,6 +117,10 @@ extension FileSystemEntityExt on FileSystemEntity { String get fileNameOnly => basename(path); } +extension IterbaleExt on LangSyncConfig { + List langsJsonFiles() => langs.map((e) => '$e.json').toList(); +} + extension StringExt on String { String tr() { return this; diff --git a/lib/src/etc/models/api_key_res.dart b/lib/src/etc/models/api_key_res.dart index d124635..501acc7 100644 --- a/lib/src/etc/models/api_key_res.dart +++ b/lib/src/etc/models/api_key_res.dart @@ -1,5 +1,6 @@ import 'package:equatable/equatable.dart'; +///! Scheduled for removal. class APIKeyResponse extends Equatable { const APIKeyResponse({ required this.username, diff --git a/lib/src/etc/models/config.dart b/lib/src/etc/models/config.dart index 568063c..02a453d 100644 --- a/lib/src/etc/models/config.dart +++ b/lib/src/etc/models/config.dart @@ -1,7 +1,11 @@ import 'package:equatable/equatable.dart'; import 'package:yaml/yaml.dart'; +/// {@template langsync_config} +/// The LangSync config model, it holds possible configurations that relates to the config file reference that will be read or/and write to. +/// {@endtemplate} class LangSyncConfig extends Equatable { + /// {@macro langsync_config} const LangSyncConfig({ required this.sourceFile, required this.outputDir, @@ -10,6 +14,7 @@ class LangSyncConfig extends Equatable { this.instruction, }); + /// Creates a [LangSyncConfig] from a [Map]. factory LangSyncConfig.fromMap(Map map) { final langsyncMapField = map['langsync'] as Map; @@ -33,13 +38,20 @@ class LangSyncConfig extends Equatable { ); } + /// The source localization file path. final String sourceFile; + + /// The output directory path. final String outputDir; + + /// The target languages to generate localizations for. final Iterable langs; + + /// The maximum language localization can take to be generated in seconds, if a language localization takes more than this value, it will be skipped. final int? languageLocalizationMaxDelay; - final String? instruction; - List get langsJsonFiles => langs.map((e) => '$e.json').toList(); + /// The AI instruction to generate localizations, if any. + final String? instruction; @override List get props => [ @@ -47,8 +59,10 @@ class LangSyncConfig extends Equatable { outputDir, langs, languageLocalizationMaxDelay, + instruction, ]; + /// Converts the [LangSyncConfig] to a [Map]. Map toMap() { return { 'source': sourceFile,