Skip to content

Commit f2f806f

Browse files
committed
Merge pull request godotengine#110323 from bruvzg/csv_text
Open translation CSV in the text editor instead of printing errors.
2 parents f1f3f06 + 9318466 commit f2f806f

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

editor/editor_node.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,12 @@ Error EditorNode::load_resource(const String &p_resource, bool p_ignore_broken_d
15561556
Error err;
15571557

15581558
Ref<Resource> res;
1559-
if (ResourceLoader::exists(p_resource, "")) {
1559+
if (force_textfile_extensions.has(p_resource.get_extension())) {
1560+
res = ResourceCache::get_ref(p_resource);
1561+
if (res.is_null() || !res->is_class("TextFile")) {
1562+
res = ScriptEditor::get_singleton()->open_file(p_resource);
1563+
}
1564+
} else if (ResourceLoader::exists(p_resource, "")) {
15601565
res = ResourceLoader::load(p_resource, "", ResourceFormatLoader::CACHE_MODE_REUSE, &err);
15611566
} else if (textfile_extensions.has(p_resource.get_extension())) {
15621567
res = ScriptEditor::get_singleton()->open_file(p_resource);
@@ -7912,6 +7917,8 @@ EditorNode::EditorNode() {
79127917
other_file_extensions.insert(E);
79137918
}
79147919

7920+
force_textfile_extensions.insert("csv"); // CSV translation source, has `Translation` resource type, but not loadable as resource.
7921+
79157922
resource_preview = memnew(EditorResourcePreview);
79167923
add_child(resource_preview);
79177924
progress_dialog = memnew(ProgressDialog);

editor/editor_node.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ class EditorNode : public Node {
477477
SceneImportSettingsDialog *scene_import_settings = nullptr;
478478
AudioStreamImportSettingsDialog *audio_stream_import_settings = nullptr;
479479

480+
HashSet<String> force_textfile_extensions;
480481
HashSet<String> textfile_extensions;
481482
HashSet<String> other_file_extensions;
482483
HashSet<FileDialog *> file_dialogs;

0 commit comments

Comments
 (0)