mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
update translation script with force option
This commit is contained in:
parent
32350b8ab2
commit
f6dfe935d6
2 changed files with 9 additions and 8 deletions
|
@ -3,13 +3,14 @@ import 'utils/translation/translation_constants.dart';
|
||||||
import 'utils/translation/translation_utils.dart';
|
import 'utils/translation/translation_utils.dart';
|
||||||
|
|
||||||
void main(List<String> args) async {
|
void main(List<String> args) async {
|
||||||
if (args.length != 2) {
|
if (args.length < 2 || args.length > 3) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
|
'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!" [--force]`');
|
||||||
}
|
}
|
||||||
|
|
||||||
final name = args.first;
|
final name = args[0];
|
||||||
final text = args.last;
|
final text = args[1];
|
||||||
|
final force = args.length == 3 && args[2] == '--force';
|
||||||
|
|
||||||
print('Appending "$name": "$text"');
|
print('Appending "$name": "$text"');
|
||||||
|
|
||||||
|
@ -18,7 +19,7 @@ void main(List<String> args) async {
|
||||||
final fileName = getArbFileName(lang);
|
final fileName = getArbFileName(lang);
|
||||||
final translation = await getTranslation(text, lang);
|
final translation = await getTranslation(text, lang);
|
||||||
|
|
||||||
appendStringToArbFile(fileName, name, translation);
|
appendStringToArbFile(fileName, name, translation, force: force);
|
||||||
}
|
}
|
||||||
|
|
||||||
print('Alphabetizing all files...');
|
print('Alphabetizing all files...');
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
void appendStringToArbFile(String fileName, String name, String text) {
|
void appendStringToArbFile(String fileName, String name, String text, {bool force = false}) {
|
||||||
final file = File(fileName);
|
final file = File(fileName);
|
||||||
final arbObj = readArbFile(file);
|
final arbObj = readArbFile(file);
|
||||||
|
|
||||||
if (arbObj.containsKey(name)) {
|
if (arbObj.containsKey(name) && !force) {
|
||||||
print("String $name already exists in $fileName!");
|
print("String $name already exists in $fileName! Use --force to overwrite!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue