File tree Expand file tree Collapse file tree 5 files changed +28
-8
lines changed Expand file tree Collapse file tree 5 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -128,6 +128,7 @@ class StartCommand extends Command<int> {
128
128
langs: asConfig.langs,
129
129
languageLocalizationMaxDelay: asConfig.languageLocalizationMaxDelay,
130
130
operationId: jsonPartitionRes.operationId,
131
+ instruction: asConfig.instruction,
131
132
);
132
133
133
134
logger
@@ -269,6 +270,7 @@ class StartCommand extends Command<int> {
269
270
required Iterable <String > langs,
270
271
required String operationId,
271
272
required int ? languageLocalizationMaxDelay,
273
+ required String ? instruction,
272
274
}) async {
273
275
final completer = Completer <LangSyncServerResultSSE >();
274
276
@@ -277,6 +279,7 @@ class StartCommand extends Command<int> {
277
279
langs: langs,
278
280
operationId: operationId,
279
281
languageLocalizationMaxDelay: languageLocalizationMaxDelay,
282
+ instruction: instruction,
280
283
);
281
284
282
285
LangSyncServerResultSSE ? resultSSE;
Original file line number Diff line number Diff line change 1
1
import 'dart:io' ;
2
2
3
3
import 'package:langsync/src/etc/controllers/config_file.dart' ;
4
+ import 'package:langsync/src/etc/extensions.dart' ;
4
5
import 'package:yaml/yaml.dart' as yaml;
5
6
6
7
class YamlController extends ConfigFile {
@@ -30,14 +31,17 @@ class YamlController extends ConfigFile {
30
31
config,
31
32
callback: (entry) async {
32
33
if (entry.value is String ) {
33
- await super .writeToConfigFile (
34
- "\n ${entry .key }: '${entry .value }' \n " ,
35
- );
36
- } else if (entry.value is List ) {
37
- await super .writeToConfigFile (
38
- '\n ${entry .key }: ${entry .value } \n ' ,
39
- );
34
+ if ((entry.value as String ).isPathToFileOrFolder ()) {
35
+ await super .writeToConfigFile (
36
+ "\n ${entry .key }: '${entry .value }' \n " ,
37
+ );
38
+ return ;
39
+ }
40
40
}
41
+
42
+ await super .writeToConfigFile (
43
+ '\n ${entry .key }: ${entry .value } \n ' ,
44
+ );
41
45
},
42
46
);
43
47
}
Original file line number Diff line number Diff line change @@ -121,4 +121,12 @@ extension StringExt on String {
121
121
String tr () {
122
122
return this ;
123
123
}
124
+
125
+ String ensureStringSymbol () {
126
+ return replaceAll ("'" , '"' );
127
+ }
128
+
129
+ bool isPathToFileOrFolder () {
130
+ return File (this ).existsSync () || Directory (this ).existsSync ();
131
+ }
124
132
}
Original file line number Diff line number Diff line change 1
1
import 'package:equatable/equatable.dart' ;
2
+ import 'package:langsync/src/etc/extensions.dart' ;
2
3
import 'package:yaml/yaml.dart' ;
3
4
4
5
class LangSyncConfig extends Equatable {
Original file line number Diff line number Diff line change 1
1
import 'dart:convert' ;
2
2
import 'dart:io' ;
3
3
import 'package:langsync/src/etc/models/api_key_res.dart' ;
4
+ import 'package:langsync/src/etc/models/config.dart' ;
4
5
import 'package:langsync/src/etc/models/lang_output.dart' ;
5
6
import 'package:langsync/src/etc/models/operation.dart' ;
6
7
import 'package:langsync/src/etc/models/result_locale.dart' ;
@@ -21,8 +22,9 @@ class NetClient extends NetClientBoilerPlate {
21
22
required Iterable <String > langs,
22
23
required String apiKey,
23
24
required String operationId,
24
- required int ? languageLocalizationMaxDelay,
25
25
bool includeOutput = false ,
26
+ required int ? languageLocalizationMaxDelay,
27
+ required String ? instruction,
26
28
}) {
27
29
return sseStreamReq <List <LangSyncServerSSE >>(
28
30
'/process-translation' ,
@@ -33,6 +35,8 @@ class NetClient extends NetClientBoilerPlate {
33
35
'langs' : langs.toList (),
34
36
'includeOutput' : includeOutput,
35
37
'languageLocalizationMaxDelay' : languageLocalizationMaxDelay,
38
+ if (instruction != null && instruction.isNotEmpty)
39
+ 'instruction' : instruction,
36
40
},
37
41
(res) {
38
42
final split = res.split ('\n\n ' ).where ((element) => element.isNotEmpty);
You can’t perform that action at this time.
0 commit comments