Skip to content

Commit

Permalink
Merge pull request #51131 from timothyqiu/i18n-android-export-3x
Browse files Browse the repository at this point in the history
[3.x] Make progress and errors translatable when exporting to Android
  • Loading branch information
akien-mga authored Aug 1, 2021
2 parents 74f28ca + 55b5234 commit 4542e33
Showing 1 changed file with 29 additions and 30 deletions.
59 changes: 29 additions & 30 deletions platform/android/export/export.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1876,12 +1876,12 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

device_lock.lock();

EditorProgress ep("run", "Running on " + devices[p_device].name, 3);
EditorProgress ep("run", vformat(TTR("Running on %s"), devices[p_device].name), 3);

String adb = get_adb_path();

// Export_temp APK.
if (ep.step("Exporting APK...", 0)) {
if (ep.step(TTR("Exporting APK..."), 0)) {
device_lock.unlock();
return ERR_SKIP;
}
Expand Down Expand Up @@ -1918,7 +1918,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String package_name = p_preset->get("package/unique_name");

if (remove_prev) {
if (ep.step("Uninstalling...", 1)) {
if (ep.step(TTR("Uninstalling..."), 1)) {
CLEANUP_AND_RETURN(ERR_SKIP);
}

Expand All @@ -1935,7 +1935,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}

print_line("Installing to device (please wait...): " + devices[p_device].name);
if (ep.step("Installing to device, please wait...", 2)) {
if (ep.step(TTR("Installing to device, please wait..."), 2)) {
CLEANUP_AND_RETURN(ERR_SKIP);
}

Expand All @@ -1950,7 +1950,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
err = OS::get_singleton()->execute(adb, args, true, nullptr, &output, &rv, true);
print_verbose(output);
if (err || rv != 0) {
EditorNode::add_io_error("Could not install to device: " + output);
EditorNode::add_io_error(vformat(TTR("Could not install to device: %s"), output));
CLEANUP_AND_RETURN(ERR_CANT_CREATE);
}

Expand Down Expand Up @@ -2006,7 +2006,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
}
}

if (ep.step("Running on device...", 3)) {
if (ep.step(TTR("Running on device..."), 3)) {
CLEANUP_AND_RETURN(ERR_SKIP);
}
args.clear();
Expand All @@ -2028,7 +2028,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
err = OS::get_singleton()->execute(adb, args, true, nullptr, &output, &rv, true);
print_verbose(output);
if (err || rv != 0) {
EditorNode::add_io_error("Could not execute on device.");
EditorNode::add_io_error(TTR("Could not execute on device."));
CLEANUP_AND_RETURN(ERR_CANT_CREATE);
}

Expand Down Expand Up @@ -2690,7 +2690,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String apksigner = get_apksigner_path();
print_verbose("Starting signing of the " + export_label + " binary using " + apksigner);
if (!FileAccess::exists(apksigner)) {
EditorNode::add_io_error("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting " + export_label + " is unsigned.");
EditorNode::add_io_error(vformat(TTR("'apksigner' could not be found.\nPlease check the command is available in the Android SDK build-tools directory.\nThe resulting %s is unsigned."), export_label));
return OK;
}

Expand All @@ -2708,7 +2708,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
user = EditorSettings::get_singleton()->get("export/android/debug_keystore_user");
}

if (ep.step("Signing debug " + export_label + "...", 104)) {
if (ep.step(vformat(TTR("Signing debug %s..."), export_label), 104)) {
return ERR_SKIP;
}

Expand All @@ -2717,13 +2717,13 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
password = release_password;
user = release_username;

if (ep.step("Signing release " + export_label + "...", 104)) {
if (ep.step(vformat(TTR("Signing release %s..."), export_label), 104)) {
return ERR_SKIP;
}
}

if (!FileAccess::exists(keystore)) {
EditorNode::add_io_error("Could not find keystore, unable to export.");
EditorNode::add_io_error(TTR("Could not find keystore, unable to export."));
return ERR_FILE_CANT_OPEN;
}

Expand All @@ -2747,11 +2747,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
OS::get_singleton()->execute(apksigner, args, true, nullptr, &output, &retval, true);
print_verbose(output);
if (retval) {
EditorNode::add_io_error("'apksigner' returned with error #" + itos(retval));
EditorNode::add_io_error(vformat(TTR("'apksigner' returned with error #%d"), retval));
return ERR_CANT_CREATE;
}

if (ep.step("Verifying " + export_label + "...", 105)) {
if (ep.step(vformat(TTR("Verifying %s..."), export_label), 105)) {
return ERR_SKIP;
}

Expand All @@ -2767,7 +2767,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
OS::get_singleton()->execute(apksigner, args, true, nullptr, &output, &retval, true);
print_verbose(output);
if (retval) {
EditorNode::add_io_error("'apksigner' verification of " + export_label + " failed.");
EditorNode::add_io_error(vformat(TTR("'apksigner' verification of %s failed."), export_label));
return ERR_CANT_CREATE;
}

Expand Down Expand Up @@ -2832,7 +2832,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String src_apk;
Error err;

EditorProgress ep("export", "Exporting for Android", 105, true);
EditorProgress ep("export", TTR("Exporting for Android"), 105, true);

bool use_custom_build = bool(p_preset->get("custom_template/use_custom_build"));
bool p_give_internet = p_flags & (DEBUG_FLAG_DUMB_CLIENT | DEBUG_FLAG_REMOTE_DEBUG);
Expand Down Expand Up @@ -2881,7 +2881,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
return ERR_UNCONFIGURED;
}
if (export_format > EXPORT_FORMAT_AAB || export_format < EXPORT_FORMAT_APK) {
EditorNode::add_io_error("Unsupported export format!\n");
EditorNode::add_io_error(TTR("Unsupported export format!\n"));
return ERR_UNCONFIGURED; //TODO: is this the right error?
}

Expand Down Expand Up @@ -2911,7 +2911,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String project_name = get_project_name(p_preset->get("package/name"));
err = _create_project_name_strings_files(p_preset, project_name); //project name localization.
if (err != OK) {
EditorNode::add_io_error("Unable to overwrite res://android/build/res/*.xml files with project name");
EditorNode::add_io_error(TTR("Unable to overwrite res://android/build/res/*.xml files with project name"));
}
// Copies the project icon files into the appropriate Gradle project directory.
_copy_icons_to_gradle_project(p_preset, processed_splash_config_xml, splash_image, splash_bg_color_image, main_image, foreground, background);
Expand All @@ -2927,7 +2927,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
user_data.debug = p_debug;
err = export_project_files(p_preset, rename_and_store_file_in_gradle_project, &user_data, copy_gradle_so);
if (err != OK) {
EditorNode::add_io_error("Could not export project files to gradle project\n");
EditorNode::add_io_error(TTR("Could not export project files to gradle project\n"));
return err;
}
if (user_data.libs.size() > 0) {
Expand All @@ -2939,7 +2939,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
print_verbose("Saving apk expansion file..");
err = save_apk_expansion_file(p_preset, p_path);
if (err != OK) {
EditorNode::add_io_error("Could not write expansion package file!");
EditorNode::add_io_error(TTR("Could not write expansion package file!"));
return err;
}
}
Expand Down Expand Up @@ -3026,7 +3026,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
String release_username = p_preset->get("keystore/release_user");
String release_password = p_preset->get("keystore/release_password");
if (!FileAccess::exists(release_keystore)) {
EditorNode::add_io_error("Could not find keystore, unable to export.");
EditorNode::add_io_error(TTR("Could not find keystore, unable to export."));
return ERR_FILE_CANT_OPEN;
}

Expand Down Expand Up @@ -3091,7 +3091,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
src_apk = find_export_template("android_release.apk");
}
if (src_apk == "") {
EditorNode::add_io_error("Package not found: " + src_apk);
EditorNode::add_io_error(vformat(TTR("Package not found: %s"), src_apk));
return ERR_FILE_NOT_FOUND;
}
}
Expand All @@ -3103,13 +3103,13 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
FileAccess *src_f = nullptr;
zlib_filefunc_def io = zipio_create_io_from_file(&src_f);

if (ep.step("Creating APK...", 0)) {
if (ep.step(TTR("Creating APK..."), 0)) {
return ERR_SKIP;
}

unzFile pkg = unzOpen2(src_apk.utf8().get_data(), &io);
if (!pkg) {
EditorNode::add_io_error("Could not find template APK to export:\n" + src_apk);
EditorNode::add_io_error(vformat(TTR("Could not find template APK to export:\n%s"), src_apk));
return ERR_FILE_NOT_FOUND;
}

Expand Down Expand Up @@ -3237,12 +3237,11 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

if (!invalid_abis.empty()) {
String unsupported_arch = String(", ").join(invalid_abis);
EditorNode::add_io_error("Missing libraries in the export template for the selected architectures: " + unsupported_arch + ".\n" +
"Please build a template with all required libraries, or uncheck the missing architectures in the export preset.");
EditorNode::add_io_error(vformat(TTR("Missing libraries in the export template for the selected architectures: %s.\nPlease build a template with all required libraries, or uncheck the missing architectures in the export preset."), unsupported_arch));
CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND);
}

if (ep.step("Adding files...", 1)) {
if (ep.step(TTR("Adding files..."), 1)) {
CLEANUP_AND_RETURN(ERR_SKIP);
}
err = OK;
Expand All @@ -3256,7 +3255,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {
if (apk_expansion) {
err = save_apk_expansion_file(p_preset, p_path);
if (err != OK) {
EditorNode::add_io_error("Could not write expansion package file!");
EditorNode::add_io_error(TTR("Could not write expansion package file!"));
return err;
}
} else {
Expand All @@ -3269,7 +3268,7 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

if (err != OK) {
unzClose(pkg);
EditorNode::add_io_error("Could not export project files");
EditorNode::add_io_error(TTR("Could not export project files"));
CLEANUP_AND_RETURN(ERR_SKIP);
}

Expand Down Expand Up @@ -3300,13 +3299,13 @@ class EditorExportPlatformAndroid : public EditorExportPlatform {

// If we're not signing the apk, then the next step should be the last.
const int next_step = should_sign ? 103 : 105;
if (ep.step("Aligning APK...", next_step)) {
if (ep.step(TTR("Aligning APK..."), next_step)) {
CLEANUP_AND_RETURN(ERR_SKIP);
}

unzFile tmp_unaligned = unzOpen2(tmp_unaligned_path.utf8().get_data(), &io);
if (!tmp_unaligned) {
EditorNode::add_io_error("Could not unzip temporary unaligned APK.");
EditorNode::add_io_error(TTR("Could not unzip temporary unaligned APK."));
CLEANUP_AND_RETURN(ERR_FILE_NOT_FOUND);
}

Expand Down

0 comments on commit 4542e33

Please sign in to comment.