cake_wallet/tool/translation_add_lang.dart
cyan c78662fbfe
CW 781 replace all print statements with printV (#1733)
* replace all print statements with printV

* restore backup error message

* missing print statements, error fixes

* Update cw_core/lib/utils/print_verbose.dart [skip ci]

* Update cw_core/lib/utils/print_verbose.dart [skip ci]

* CW-846: Correctly display balance (#1848)

* Correctly display balance even with frozen coins

* remove package= from AndroidMainfest.xml

* update namespace

* print -> printV

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-12-09 20:23:59 +02:00

38 lines
1.1 KiB
Dart

import 'dart:io';
import 'package:cw_core/utils/print_verbose.dart';
import 'utils/translation/arb_file_utils.dart';
import 'utils/translation/translation_constants.dart';
import 'utils/translation/translation_utils.dart';
void main(List<String> args) async {
if (args.length != 1) {
throw Exception(
'Insufficient arguments!\n\nTry to run `./translation_add_lang.dart langCode`');
}
final targetLang = args.first;
final fileName = getArbFileName(defaultLang);
final file = File(fileName);
final arbObj = readArbFile(file);
final targetFileName = getArbFileName(targetLang);
final targetKeys = arbObj.keys;
final targetFile = File(targetFileName);
targetFile.createSync(exclusive: true);
targetFile.writeAsStringSync("{}");
final translations = Map<String, String>();
for (var targetKey in targetKeys) {
final srcString = arbObj[targetKey] as String;
final translation = await getTranslation(srcString, targetLang);
translations[targetKey] = translation;
}
appendStringsToArbFile(targetFileName, translations);
printV("Success! Please add your Language Code to lib/entities/language_service.dart");
}