summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-07-05 22:35:18 +0200
committerGitHub <noreply@github.com>2020-07-05 22:35:18 +0200
commitc95fbd50fef4f648fef28e9435726a40ee7b7e2e (patch)
treecf5df9d12bf5e8e608c4413f47aee6005e624120 /modules
parent7e38e8fdb0c05f0216e4322806315a025dc05b6f (diff)
parentcae6f0bda282c8e831cbae5d45cfaa4e841ff3bf (diff)
Merge pull request #40102 from SkyLucilfer/PotGenerationFix
Change translation parser plugin API to parse_file()
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/editor/gdscript_translation_parser_plugin.cpp37
-rw-r--r--modules/gdscript/editor/gdscript_translation_parser_plugin.h1
2 files changed, 7 insertions, 31 deletions
diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp
index a1b18978fc..6d454e43f2 100644
--- a/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp
+++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.cpp
@@ -38,25 +38,8 @@ void GDScriptEditorTranslationParserPlugin::get_recognized_extensions(List<Strin
}
Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Vector<String> *r_extracted_strings) {
- List<String> extensions;
- get_recognized_extensions(&extensions);
- bool extension_valid = false;
- for (auto E = extensions.front(); E; E = E->next()) {
- if (p_path.get_extension() == E->get()) {
- extension_valid = true;
- break;
- }
- }
-
- if (!extension_valid) {
- Vector<String> temp;
- for (auto E = extensions.front(); E; E = E->next()) {
- temp.push_back(E->get());
- }
- String valid_extensions = String(", ").join(temp);
- ERR_PRINT("Argument p_path \"" + p_path + "\" has wrong extension. List of valid extensions: " + valid_extensions);
- return ERR_INVALID_PARAMETER;
- }
+ // Parse and match all GDScript function API that involves translation string.
+ // E.g get_node("Label").text = "something", var test = tr("something"), "something" will be matched and collected.
Error err;
RES loaded_res = ResourceLoader::load(p_path, "", false, &err);
@@ -66,26 +49,18 @@ Error GDScriptEditorTranslationParserPlugin::parse_file(const String &p_path, Ve
}
Ref<GDScript> gdscript = loaded_res;
- parse_text(gdscript->get_source_code(), r_extracted_strings);
-
- return OK;
-}
-
-void GDScriptEditorTranslationParserPlugin::parse_text(const String &p_text, Vector<String> *r_extracted_strings) {
- // Parse and match all GDScript function API that involves translation string.
- // E.g get_node("Label").text = "something", var test = tr("something"), "something" will be matched and collected.
-
+ String source_code = gdscript->get_source_code();
Vector<String> parsed_strings;
// Search translation strings with RegEx.
regex.clear();
regex.compile(String("|").join(patterns));
- Array results = regex.search_all(p_text);
+ Array results = regex.search_all(source_code);
_get_captured_strings(results, &parsed_strings);
// Special handling for FileDialog.
Vector<String> temp;
- _parse_file_dialog(p_text, &temp);
+ _parse_file_dialog(source_code, &temp);
parsed_strings.append_array(temp);
// Filter out / and +
@@ -97,6 +72,8 @@ void GDScriptEditorTranslationParserPlugin::parse_text(const String &p_text, Vec
}
r_extracted_strings->append_array(parsed_strings);
+
+ return OK;
}
void GDScriptEditorTranslationParserPlugin::_parse_file_dialog(const String &p_source_code, Vector<String> *r_output) {
diff --git a/modules/gdscript/editor/gdscript_translation_parser_plugin.h b/modules/gdscript/editor/gdscript_translation_parser_plugin.h
index ef967845b9..efef8f8249 100644
--- a/modules/gdscript/editor/gdscript_translation_parser_plugin.h
+++ b/modules/gdscript/editor/gdscript_translation_parser_plugin.h
@@ -48,7 +48,6 @@ class GDScriptEditorTranslationParserPlugin : public EditorTranslationParserPlug
public:
virtual Error parse_file(const String &p_path, Vector<String> *r_extracted_strings);
- virtual void parse_text(const String &p_text, Vector<String> *r_extracted_strings);
virtual void get_recognized_extensions(List<String> *r_extensions) const;
GDScriptEditorTranslationParserPlugin();