Skip to content

Commit

Permalink
[ Edit ]
Browse files Browse the repository at this point in the history
  • Loading branch information
anasfik committed Sep 30, 2023
1 parent 528c727 commit 41fb919
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 15 deletions.
Binary file removed bin/langsync.exe
Binary file not shown.
59 changes: 48 additions & 11 deletions lib/src/commands/start_command/start_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class StartCommand extends Command<int> {
await _writeNewLocalizationFiles(
outputList: outputList,
outputDir: Directory(asConfig.outputDir),
partitionId: jsonPartitionRes.partitionId,
);

logger.success('All done!');
Expand Down Expand Up @@ -173,24 +174,60 @@ class StartCommand extends Command<int> {
Future<void> _writeNewLocalizationFiles({
required List<LangOutput> outputList,
required Directory outputDir,
required String partitionId,
}) async {
for (var index = 0; index < outputList.length; index++) {
final current = outputList[index];
final fileName = '${current.lang}.json';

final progress = logger.customProgress('creating $fileName..');
final isError = current.jsonFormattedResponse['error'] != null;
if (isError) {
final fileName = '${current.lang}.error.json';

final file = File('${outputDir.path}/$fileName');
logger.err(
'An error occurred while localizing to ${current.lang} file, see $fileName for more details.',
);

await file.create();
await file.writeAsString(
const JsonEncoder.withIndent(' ')
.convert(current.jsonFormattedResponse),
);
final progress = logger.progress(
'Creating error file ${current.lang}.error.json file..',
);

progress.complete('file $fileName is created successfully, ${file.path}');
}
final file = File('${outputDir.path}/$fileName');

await file.create();

await file.writeAsString(
const JsonEncoder.withIndent(' ').convert(
{
...current.jsonFormattedResponse,
'partitionId': partitionId,
'lang': current.lang,
'LocalizationTryDate': current.localizedAt,
'message':
'if you need guide on this, please contact us with the content of this file.',
},
),
);

progress.complete(
'file $fileName is created successfully, ${file.path}',
);
} else {
final fileName = '${current.lang}.json';
final progress = logger.customProgress('creating $fileName..');

logger.success('All files are created successfully.');
final file = File('${outputDir.path}/$fileName');

await file.create();
await file.writeAsString(
const JsonEncoder.withIndent(' ')
.convert(current.jsonFormattedResponse),
);

progress
.complete('file $fileName is created successfully, ${file.path}');
}

logger.success('All files are created successfully.');
}
}
}
2 changes: 1 addition & 1 deletion lib/src/etc/extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extension LoggerExt on Logger {
required String update,
required Object error,
}) {
const isDebugMode = false;
const isDebugMode = true;

if (isDebugMode) {
progress.fail(error.toString());
Expand Down
2 changes: 1 addition & 1 deletion lib/src/etc/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class Utils {
}

String endpoint(String path) {
return 'http://192.168.0.3:5559${path.startsWith("/") ? path : "/$path"}';
return 'https://api.langsync.app${path.startsWith("/") ? path : "/$path"}';
}

List<String> randomLoadingFrames() {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1 +1 @@
const packageVersion = '0.0.7';
const packageVersion = '0.7.0';
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: langsync
description: A Very Good Project created by Very Good CLI.
version: 0.0.7
version: 0.7.0
publish_to: none

environment:
Expand Down

0 comments on commit 41fb919

Please sign in to comment.