diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp index 58f0c7def08..4bbf5ba3166 100644 --- a/editor/import/resource_importer_csv_translation.cpp +++ b/editor/import/resource_importer_csv_translation.cpp @@ -73,16 +73,25 @@ String ResourceImporterCSVTranslation::get_preset_name(int p_idx) const { void ResourceImporterCSVTranslation::get_import_options(List *r_options, int p_preset) const { r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "compress"), true)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "delimiter", PROPERTY_HINT_ENUM, "Comma,Semicolon,Tab"), 0)); } Error ResourceImporterCSVTranslation::import(const String &p_source_file, const String &p_save_path, const Map &p_options, List *r_platform_variants, List *r_gen_files) { bool compress = p_options["compress"]; + + String delimiter; + switch ((int)p_options["delimiter"]) { + case 0: delimiter = ","; break; + case 1: delimiter = ";"; break; + case 2: delimiter = "\t"; break; + } + FileAccessRef f = FileAccess::open(p_source_file, FileAccess::READ); ERR_FAIL_COND_V(!f, ERR_INVALID_PARAMETER); - Vector line = f->get_csv_line(); + Vector line = f->get_csv_line(delimiter); ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR); Vector locales; @@ -101,7 +110,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const translations.push_back(translation); } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); while (line.size() == locales.size() + 1) { @@ -113,7 +122,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const } } - line = f->get_csv_line(); + line = f->get_csv_line(delimiter); } for (int i = 0; i < translations.size(); i++) {