mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-24 20:49:28 +00:00
f6670c0236
* Added CoinsInfo to monero_api_cpp * Add struct on dart * Add struct on dart * Set coins value * CW-415 Use add-coin-to-monero branch * CW-415 Add get Coin and build Monero Deps using Docker * CW-415 Fix Typo * CW-415 add debug log info * CW-415 Add preferred key Images for coin control to Monero * CW-415 Fix generation * CW-415 Skip GA Cache Externals * CW-415 Skip GA Cache Externals * CW-415 Coin Control: remove Block Explorer for Monero, Add Tx hash, save note on field exit * CW-415 Coin Control: Throw Exception when all outputs are deselected * CW-415 Coin Control: Show Frozen Balance on Dashboard * CW-415 Coin Control: Show Frozen Balance on Dashboard * CW-415 Ignore cached Monero deps in Workflow * CW-415 Fix displaying frozen Balance * Use own Translator with http 1.1.0 * CW-415 Resolve requested Changes * CW-415 Resolve requested Changes * CW-415 Resolve requested Changes * CW-415 Apply requested Changes * CW-415 Apply requested Changes * CW-415 Ensure opening of UnspentCoinsInfo Box, even for Monero.com --------- Co-authored-by: Konstantin Ullrich <konstantinullrich12@gmail.com>
66 lines
1.7 KiB
Dart
66 lines
1.7 KiB
Dart
import 'dart:convert';
|
|
import 'dart:io';
|
|
|
|
import 'package:translator/translator.dart';
|
|
|
|
const defaultLang = "en";
|
|
const langs = [
|
|
"ar", "bg", "cs", "de", "en", "es", "fr", "ha", "hi", "hr", "id", "it",
|
|
"ja", "ko", "my", "nl", "pl", "pt", "ru", "th", "tr", "uk", "ur", "yo",
|
|
"zh-cn" // zh, but Google Translate uses zh-cn for Chinese (Simplified)
|
|
];
|
|
final translator = GoogleTranslator();
|
|
|
|
void main(List<String> args) async {
|
|
if (args.length != 2) {
|
|
throw Exception(
|
|
'Insufficient arguments!\n\nTry to run `./append_translation.dart greetings "Hello World!"`');
|
|
}
|
|
|
|
final name = args.first;
|
|
final text = args.last;
|
|
|
|
print('Appending "$name": "$text"');
|
|
|
|
for (var lang in langs) {
|
|
final fileName = getFileName(lang);
|
|
final translation = await getTranslation(text, lang);
|
|
|
|
appendArbFile(fileName, name, translation);
|
|
}
|
|
}
|
|
|
|
void appendArbFile(String fileName, String name, String text) {
|
|
final file = File(fileName);
|
|
final inputContent = file.readAsStringSync();
|
|
final arbObj = json.decode(inputContent) as Map<String, dynamic>;
|
|
|
|
if (arbObj.containsKey(name)) {
|
|
print("String $name already exists in $fileName!");
|
|
return;
|
|
}
|
|
|
|
arbObj.addAll({name: text});
|
|
|
|
final outputContent = json
|
|
.encode(arbObj)
|
|
.replaceAll('","', '",\n "')
|
|
.replaceAll('{"', '{\n "')
|
|
.replaceAll('"}', '"\n}')
|
|
.replaceAll('":"', '": "');
|
|
|
|
file.writeAsStringSync(outputContent);
|
|
}
|
|
|
|
|
|
Future<String> getTranslation(String text, String lang) async {
|
|
if (lang == defaultLang) return text;
|
|
return (await translator.translate(text, from: defaultLang, to: lang)).text;
|
|
}
|
|
|
|
String getFileName(String lang) {
|
|
final shortLang = lang
|
|
.split("-")
|
|
.first;
|
|
return "./res/values/strings_$shortLang.arb";
|
|
}
|