summaryrefslogtreecommitdiffstats
path: root/editor/import/resource_importer_csv_translation.cpp
diff options
context:
space:
mode:
authorjsjtxietian <jsjtxietian@outlook.com>2023-10-19 12:55:35 +0800
committerjsjtxietian <jsjtxietian@outlook.com>2023-10-20 16:17:29 +0800
commit0099791fc05e6648b2c8c3e01efc89e3b2e925e4 (patch)
treeb6226b5bb57ad37fd33379aec17dda6fd967a45f /editor/import/resource_importer_csv_translation.cpp
parentdce1aab174369e9124507f4614fc007301df52e7 (diff)
downloadredot-engine-0099791fc05e6648b2c8c3e01efc89e3b2e925e4.tar.gz
Make translation importer skip not-supported lang tag
Also give better warning.
Diffstat (limited to 'editor/import/resource_importer_csv_translation.cpp')
-rw-r--r--editor/import/resource_importer_csv_translation.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index 92d244c79a..5d45292222 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -96,10 +96,16 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
Vector<String> locales;
Vector<Ref<Translation>> translations;
+ HashSet<int> skipped_locales;
for (int i = 1; i < line.size(); i++) {
String locale = TranslationServer::get_singleton()->standardize_locale(line[i]);
+ if (locale.is_empty()) {
+ skipped_locales.insert(i);
+ ERR_CONTINUE_MSG(true, vformat("Error importing CSV translation: Invalid locale format '%s', should be 'language_Script_COUNTRY_VARIANT@extra'.", line[i]));
+ }
+
locales.push_back(locale);
Ref<Translation> translation;
translation.instantiate();
@@ -111,9 +117,12 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
line = f->get_csv_line(delimiter);
String key = line[0];
if (!key.is_empty()) {
- ERR_FAIL_COND_V_MSG(line.size() != locales.size() + 1, ERR_PARSE_ERROR, vformat("Error importing CSV translation: expected %d locale(s), but the '%s' key has %d locale(s).", locales.size(), key, line.size() - 1));
+ ERR_CONTINUE_MSG(line.size() != locales.size() + 1, vformat("Error importing CSV translation: expected %d locale(s), but the '%s' key has %d locale(s).", locales.size(), key, line.size() - 1));
for (int i = 1; i < line.size(); i++) {
+ if (skipped_locales.has(i)) {
+ continue;
+ }
translations.write[i - 1]->add_message(key, line[i].c_unescape());
}
}