summaryrefslogtreecommitdiff
path: root/editor/editor_translation_parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'editor/editor_translation_parser.cpp')
-rw-r--r--editor/editor_translation_parser.cpp29
1 files changed, 6 insertions, 23 deletions
diff --git a/editor/editor_translation_parser.cpp b/editor/editor_translation_parser.cpp
index 1f08a985f1..3f4864ad1e 100644
--- a/editor/editor_translation_parser.cpp
+++ b/editor/editor_translation_parser.cpp
@@ -41,33 +41,16 @@ Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<Str
if (!get_script_instance())
return ERR_UNAVAILABLE;
- if (get_script_instance()->has_method("parse_text")) {
- Error err;
- FileAccess *file = FileAccess::open(p_path, FileAccess::READ, &err);
- if (err != OK) {
- ERR_PRINT("Failed to open " + p_path);
- return err;
- }
- parse_text(file->get_as_utf8_string(), r_extracted_strings);
- return OK;
- } else {
- ERR_PRINT("Custom translation parser plugin's \"func parse_text(text, extracted_strings)\" is undefined.");
- return ERR_UNAVAILABLE;
- }
-}
-
-void EditorTranslationParserPlugin::parse_text(const String &p_text, Vector<String> *r_extracted_strings) {
- if (!get_script_instance())
- return;
-
- if (get_script_instance()->has_method("parse_text")) {
+ if (get_script_instance()->has_method("parse_file")) {
Array extracted_strings;
- get_script_instance()->call("parse_text", p_text, extracted_strings);
+ get_script_instance()->call("parse_file", p_path, extracted_strings);
for (int i = 0; i < extracted_strings.size(); i++) {
r_extracted_strings->append(extracted_strings[i]);
}
+ return OK;
} else {
- ERR_PRINT("Custom translation parser plugin's \"func parse_text(text, extracted_strings)\" is undefined.");
+ ERR_PRINT("Custom translation parser plugin's \"func parse_file(path, extracted_strings)\" is undefined.");
+ return ERR_UNAVAILABLE;
}
}
@@ -86,7 +69,7 @@ void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_ex
}
void EditorTranslationParserPlugin::_bind_methods() {
- ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::NIL, "parse_text", PropertyInfo(Variant::STRING, "text"), PropertyInfo(Variant::ARRAY, "extracted_strings")));
+ ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::NIL, "parse_file", PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::ARRAY, "extracted_strings")));
ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::ARRAY, "get_recognized_extensions"));
}