From 2323464f5ed3dbf4f80899abf4c3fb0dd08a2693 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 21 Jan 2019 18:34:53 +0100 Subject: [PATCH] ExportDialog: Make error messages translatable Also fix missing newlines that caused #24202. --- editor/editor_export.cpp | 6 ++-- platform/android/export/export.cpp | 49 +++++++++------------------ platform/iphone/export/export.cpp | 24 ++++++------- platform/javascript/export/export.cpp | 4 +-- platform/osx/export/export.cpp | 4 +-- platform/uwp/export/export.cpp | 26 +++++++------- 6 files changed, 48 insertions(+), 65 deletions(-) diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index b36ed72125e..7c99318dca5 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -378,7 +378,7 @@ String EditorExportPlatform::find_export_template(String template_file_name, Str // Not found if (err) { - *err += "No export template found at \"" + template_path + "\"."; + *err += TTR("No export template found at the expected path:") + "\n" + template_path + "\n"; } return String(); } @@ -1404,12 +1404,12 @@ bool EditorExportPlatformPC::can_export(const Ref &p_preset, if (!FileAccess::exists(custom_debug_binary)) { dvalid = false; - err = "Custom debug binary not found.\n"; + err += TTR("Custom debug template not found.") + "\n"; } if (!FileAccess::exists(custom_release_binary)) { rvalid = false; - err += "Custom release binary not found.\n"; + err += TTR("Custom release template not found.") + "\n"; } if (dvalid || rvalid) diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 405fe0b2940..f293eef2bae 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -426,7 +426,7 @@ class EditorExportAndroid : public EditorExportPlatform { if (pname.length() == 0) { if (r_error) { - *r_error = "Package name is missing."; + *r_error = TTR("Package name is missing."); } return false; } @@ -437,7 +437,7 @@ class EditorExportAndroid : public EditorExportPlatform { CharType c = pname[i]; if (first && c == '.') { if (r_error) { - *r_error = "Package segments must be of non-zero length."; + *r_error = TTR("Package segments must be of non-zero length."); } return false; } @@ -448,19 +448,19 @@ class EditorExportAndroid : public EditorExportPlatform { } if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { if (r_error) { - *r_error = "The character '" + String::chr(c) + "' is not allowed in Android application package names."; + *r_error = vformat(TTR("The character '%s' is not allowed in Android application package names."), String::chr(c)); } return false; } if (first && (c >= '0' && c <= '9')) { if (r_error) { - *r_error = "A digit cannot be the first character in a package segment."; + *r_error = TTR("A digit cannot be the first character in a package segment."); } return false; } if (first && c == '_') { if (r_error) { - *r_error = "The character '" + String::chr(c) + "' cannot be the first character in a package segment."; + *r_error = vformat(TTR("The character '%s' cannot be the first character in a package segment."), String::chr(c)); } return false; } @@ -469,14 +469,14 @@ class EditorExportAndroid : public EditorExportPlatform { if (segments == 0) { if (r_error) { - *r_error = "The package must have at least one '.' separator."; + *r_error = TTR("The package must have at least one '.' separator."); } return false; } if (first) { if (r_error) { - *r_error = "Package segments must be of non-zero length."; + *r_error = TTR("Package segments must be of non-zero length."); } return false; } @@ -584,7 +584,7 @@ class EditorExportAndroid : public EditorExportPlatform { static Error save_apk_so(void *p_userdata, const SharedObject &p_so) { if (!p_so.path.get_file().begins_with("lib")) { String err = "Android .so file names must start with \"lib\", but got: " + p_so.path; - ERR_PRINT(err.utf8().get_data()); + ERR_PRINTS(err); return FAILED; } APKExportData *ed = (APKExportData *)p_userdata; @@ -605,7 +605,7 @@ class EditorExportAndroid : public EditorExportPlatform { if (!exported) { String abis_string = String(" ").join(abis); String err = "Cannot determine ABI for library \"" + p_so.path + "\". One of the supported ABIs must be used as a tag: " + abis_string; - ERR_PRINT(err.utf8().get_data()); + ERR_PRINTS(err); return FAILED; } return OK; @@ -1390,7 +1390,7 @@ public: if (FileAccess::exists(p_preset->get("custom_package/debug"))) { r_missing_templates = false; } else { - err += "Custom debug package not found.\n"; + err += TTR("Custom debug template not found.") + "\n"; } } @@ -1398,7 +1398,7 @@ public: if (FileAccess::exists(p_preset->get("custom_package/release"))) { r_missing_templates = false; } else { - err += "Custom release package not found.\n"; + err += TTR("Custom release template not found.") + "\n"; } } @@ -1409,7 +1409,7 @@ public: if (!FileAccess::exists(adb)) { valid = false; - err += "ADB executable not configured in the Editor Settings.\n"; + err += TTR("ADB executable not configured in the Editor Settings.") + "\n"; } String js = EditorSettings::get_singleton()->get("export/android/jarsigner"); @@ -1417,7 +1417,7 @@ public: if (!FileAccess::exists(js)) { valid = false; - err += "OpenJDK 8 jarsigner not configured in the Editor Settings.\n"; + err += TTR("OpenJDK jarsigner not configured in the Editor Settings.") + "\n"; } String dk = p_preset->get("keystore/debug"); @@ -1427,7 +1427,7 @@ public: dk = EditorSettings::get_singleton()->get("export/android/debug_keystore"); if (!FileAccess::exists(dk)) { valid = false; - err += "Debug keystore not configured in the Editor Settings nor in the preset.\n"; + err += TTR("Debug keystore not configured in the Editor Settings nor in the preset.") + "\n"; } } @@ -1435,19 +1435,12 @@ public: if (apk_expansion) { - /* - if (apk_expansion_salt=="") { - valid=false; - err+="Invalid SALT for apk expansion.\n"; - } - */ - String apk_expansion_pkey = p_preset->get("apk_expansion/public_key"); if (apk_expansion_pkey == "") { valid = false; - err += "Invalid public key for APK expansion.\n"; + err += TTR("Invalid public key for APK expansion.") + "\n"; } } @@ -1457,7 +1450,7 @@ public: if (!is_package_name_valid(get_package_name(pn), &pn_err)) { valid = false; - err += "Invalid package name - " + pn_err + "\n"; + err += TTR("Invalid package name:") + " " + pn_err + "\n"; } r_error = err; @@ -1656,16 +1649,6 @@ public: if (p_flags & DEBUG_FLAG_DUMB_CLIENT) { - /*String host = EditorSettings::get_singleton()->get("filesystem/file_server/host"); - int port = EditorSettings::get_singleton()->get("filesystem/file_server/post"); - String passwd = EditorSettings::get_singleton()->get("filesystem/file_server/password"); - cl.push_back("--remote-fs"); - cl.push_back(host+":"+itos(port)); - if (passwd!="") { - cl.push_back("--remote-fs-password"); - cl.push_back(passwd); - }*/ - APKExportData ed; ed.ep = &ep; ed.apk = unaligned_apk; diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index ef81981ec00..849e6d4a145 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -105,7 +105,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { if (pname.length() == 0) { if (r_error) { - *r_error = "Identifier is missing."; + *r_error = TTR("Identifier is missing."); } return false; } @@ -116,7 +116,7 @@ class EditorExportPlatformIOS : public EditorExportPlatform { CharType c = pname[i]; if (first && c == '.') { if (r_error) { - *r_error = "Identifier segments must be of non-zero length."; + *r_error = TTR("Identifier segments must be of non-zero length."); } return false; } @@ -127,19 +127,19 @@ class EditorExportPlatformIOS : public EditorExportPlatform { } if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || c == '_')) { if (r_error) { - *r_error = "The character '" + String::chr(c) + "' is not allowed in Identifier."; + *r_error = vformat(TTR("The character '%s' is not allowed in Identifier."), String::chr(c)); } return false; } if (first && (c >= '0' && c <= '9')) { if (r_error) { - *r_error = "A digit cannot be the first character in a Identifier segment."; + *r_error = TTR("A digit cannot be the first character in a Identifier segment."); } return false; } if (first && c == '_') { if (r_error) { - *r_error = "The character '" + String::chr(c) + "' cannot be the first character in a Identifier segment."; + *r_error = vformat(TTR("The character '%s' cannot be the first character in a Identifier segment."), String::chr(c)); } return false; } @@ -148,14 +148,14 @@ class EditorExportPlatformIOS : public EditorExportPlatform { if (segments == 0) { if (r_error) { - *r_error = "The Identifier must have at least one '.' separator."; + *r_error = TTR("The Identifier must have at least one '.' separator."); } return false; } if (first) { if (r_error) { - *r_error = "Identifier segments must be of non-zero length."; + *r_error = TTR("Identifier segments must be of non-zero length."); } return false; } @@ -1036,7 +1036,7 @@ bool EditorExportPlatformIOS::can_export(const Ref &p_preset if (FileAccess::exists(p_preset->get("custom_package/debug"))) { r_missing_templates = false; } else { - err += "Custom debug package not found.\n"; + err += TTR("Custom debug template not found.") + "\n"; } } @@ -1044,7 +1044,7 @@ bool EditorExportPlatformIOS::can_export(const Ref &p_preset if (FileAccess::exists(p_preset->get("custom_package/release"))) { r_missing_templates = false; } else { - err += "Custom release package not found.\n"; + err += TTR("Custom release template not found.") + "\n"; } } @@ -1052,14 +1052,14 @@ bool EditorExportPlatformIOS::can_export(const Ref &p_preset String team_id = p_preset->get("application/app_store_team_id"); if (team_id.length() == 0) { - err += "App Store Team ID not specified - cannot configure the project.\n"; + err += TTR("App Store Team ID not specified - cannot configure the project.") + "\n"; valid = false; } String identifier = p_preset->get("application/identifier"); String pn_err; if (!is_package_name_valid(identifier, &pn_err)) { - err += "Invalid Identifier - " + pn_err + "\n"; + err += TTR("Invalid Identifier:") + " " + pn_err + "\n"; valid = false; } @@ -1068,7 +1068,7 @@ bool EditorExportPlatformIOS::can_export(const Ref &p_preset String icon_path = p_preset->get(info.preset_key); if (icon_path.length() == 0) { if (info.is_required) { - err += "Required icon is not specified in the preset.\n"; + err += TTR("Required icon is not specified in the preset.") + "\n"; valid = false; } break; diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index b3f90b90110..123c6ae6451 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -155,7 +155,7 @@ bool EditorExportPlatformJavaScript::can_export(const Ref &p if (FileAccess::exists(p_preset->get("custom_template/debug"))) { valid = true; } else { - err += "Custom debug template not found.\n"; + err += TTR("Custom debug template not found.") + "\n"; } } @@ -163,7 +163,7 @@ bool EditorExportPlatformJavaScript::can_export(const Ref &p if (FileAccess::exists(p_preset->get("custom_template/release"))) { valid = true; } else { - err += "Custom release template not found.\n"; + err += TTR("Custom release template not found.") + "\n"; } } diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 845ef4e8933..b8f6977b39d 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -749,7 +749,7 @@ bool EditorExportPlatformOSX::can_export(const Ref &p_preset if (FileAccess::exists(p_preset->get("custom_package/debug"))) { valid = true; } else { - err += "Custom debug package not found.\n"; + err += TTR("Custom debug template not found.") + "\n"; } } @@ -757,7 +757,7 @@ bool EditorExportPlatformOSX::can_export(const Ref &p_preset if (FileAccess::exists(p_preset->get("custom_package/release"))) { valid = true; } else { - err += "Custom release package not found.\n"; + err += TTR("Custom release template not found.") + "\n"; } } diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index 4dcb6cf38ec..6808016f134 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -1151,12 +1151,12 @@ public: if (!FileAccess::exists(custom_debug_binary)) { dvalid = false; - err = "\nCustom debug binary not found."; + err += TTR("Custom debug template not found.") + "\n"; } if (!FileAccess::exists(custom_release_binary)) { rvalid = false; - err += "\nCustom release binary not found."; + err += TTR("Custom release template not found.") + "\n"; } if (dvalid || rvalid) @@ -1169,57 +1169,57 @@ public: if (!_valid_resource_name(p_preset->get("package/unique_name"))) { valid = false; - err += "\nInvalid unique name."; + err += TTR("Invalid package unique name.") + "\n"; } if (!_valid_guid(p_preset->get("identity/product_guid"))) { valid = false; - err += "\nInvalid product GUID."; + err += TTR("Invalid product GUID.") + "\n"; } if (!_valid_guid(p_preset->get("identity/publisher_guid"))) { valid = false; - err += "\nInvalid publisher GUID."; + err += TTR("Invalid publisher GUID.") + "\n"; } if (!_valid_bgcolor(p_preset->get("images/background_color"))) { valid = false; - err += "\nInvalid background color."; + err += TTR("Invalid background color.") + "\n"; } if (!p_preset->get("images/store_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/store_logo"))), 50, 50)) { valid = false; - err += "\nInvalid Store Logo image dimensions (should be 50x50)."; + err += TTR("Invalid Store Logo image dimensions (should be 50x50).") + "\n"; } if (!p_preset->get("images/square44x44_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/square44x44_logo"))), 44, 44)) { valid = false; - err += "\nInvalid square 44x44 logo image dimensions (should be 44x44)."; + err += TTR("Invalid square 44x44 logo image dimensions (should be 44x44).") + "\n"; } if (!p_preset->get("images/square71x71_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/square71x71_logo"))), 71, 71)) { valid = false; - err += "\nInvalid square 71x71 logo image dimensions (should be 71x71)."; + err += TTR("Invalid square 71x71 logo image dimensions (should be 71x71).") + "\n"; } if (!p_preset->get("images/square150x150_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/square150x150_logo"))), 150, 0)) { valid = false; - err += "\nInvalid square 150x150 logo image dimensions (should be 150x150)."; + err += TTR("Invalid square 150x150 logo image dimensions (should be 150x150).") + "\n"; } if (!p_preset->get("images/square310x310_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/square310x310_logo"))), 310, 310)) { valid = false; - err += "\nInvalid square 310x310 logo image dimensions (should be 310x310)."; + err += TTR("Invalid square 310x310 logo image dimensions (should be 310x310).") + "\n"; } if (!p_preset->get("images/wide310x150_logo").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/wide310x150_logo"))), 310, 150)) { valid = false; - err += "\nInvalid wide 310x150 logo image dimensions (should be 310x150)."; + err += TTR("Invalid wide 310x150 logo image dimensions (should be 310x150).") + "\n"; } if (!p_preset->get("images/splash_screen").is_zero() && !_valid_image((Object::cast_to((Object *)p_preset->get("images/splash_screen"))), 620, 300)) { valid = false; - err += "\nInvalid splash screen image dimensions (should be 620x300)."; + err += TTR("Invalid splash screen image dimensions (should be 620x300).") + "\n"; } r_error = err;