summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/import/resource_importer_csv_translation.cpp15
1 files changed, 12 insertions, 3 deletions
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index 58f0c7def0..4bbf5ba316 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<ImportOption> *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<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *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<String> line = f->get_csv_line();
+ Vector<String> line = f->get_csv_line(delimiter);
ERR_FAIL_COND_V(line.size() <= 1, ERR_PARSE_ERROR);
Vector<String> 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++) {