Merge pull request #84569 from jsjtxietian/Add-ignorable-columns-to-translation-CSVs

Add support for comment (ignorable) column in translation csv
This commit is contained in:
Rémi Verschelde 2024-02-20 11:12:03 +01:00
commit c187d6522b
No known key found for this signature in database
GPG Key ID: C3336907360768E1
1 changed files with 6 additions and 3 deletions

View File

@ -101,9 +101,12 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
for (int i = 1; i < line.size(); i++) {
String locale = TranslationServer::get_singleton()->standardize_locale(line[i]);
if (locale.is_empty()) {
if (line[i].left(1) == "_") {
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]));
continue;
} else 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'. This column will be ignored.", line[i]));
}
locales.push_back(locale);
@ -117,7 +120,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
line = f->get_csv_line(delimiter);
String key = line[0];
if (!key.is_empty()) {
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));
ERR_CONTINUE_MSG(line.size() != locales.size() + (int)skipped_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)) {