Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for comment (ignorable) column in translation csv #84569

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions editor/import/resource_importer_csv_translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)) {
Expand Down
Loading