|
@@ -58,6 +58,15 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
|
|
String node_type = state->get_node_type(i);
|
|
String node_type = state->get_node_type(i);
|
|
String parent_path = state->get_node_path(i, true);
|
|
String parent_path = state->get_node_path(i, true);
|
|
|
|
|
|
|
|
+ // Handle instanced scenes.
|
|
|
|
+ if (node_type.is_empty()) {
|
|
|
|
+ Ref<PackedScene> instance = state->get_node_instance(i);
|
|
|
|
+ if (instance.is_valid()) {
|
|
|
|
+ Ref<SceneState> _state = instance->get_state();
|
|
|
|
+ node_type = _state->get_node_type(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Find the `auto_translate_mode` property.
|
|
// Find the `auto_translate_mode` property.
|
|
bool auto_translating = true;
|
|
bool auto_translating = true;
|
|
bool auto_translate_mode_found = false;
|
|
bool auto_translate_mode_found = false;
|
|
@@ -118,7 +127,8 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
|
|
|
|
|
|
for (int j = 0; j < state->get_node_property_count(i); j++) {
|
|
for (int j = 0; j < state->get_node_property_count(i); j++) {
|
|
String property_name = state->get_node_property_name(i, j);
|
|
String property_name = state->get_node_property_name(i, j);
|
|
- if (!lookup_properties.has(property_name) || (exception_list.has(node_type) && exception_list[node_type].has(property_name))) {
|
|
|
|
|
|
+
|
|
|
|
+ if (!match_property(property_name, node_type)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -134,15 +144,6 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
|
|
parsed_strings.append_array(temp);
|
|
parsed_strings.append_array(temp);
|
|
r_ids_ctx_plural->append_array(ids_context_plural);
|
|
r_ids_ctx_plural->append_array(ids_context_plural);
|
|
}
|
|
}
|
|
- } else if ((node_type == "MenuButton" || node_type == "OptionButton") && property_name == "items") {
|
|
|
|
- Vector<String> str_values = property_value;
|
|
|
|
- int incr_value = node_type == "MenuButton" ? PopupMenu::ITEM_PROPERTY_SIZE : OptionButton::ITEM_PROPERTY_SIZE;
|
|
|
|
- for (int k = 0; k < str_values.size(); k += incr_value) {
|
|
|
|
- String desc = str_values[k].get_slice(";", 1).strip_edges();
|
|
|
|
- if (!desc.is_empty()) {
|
|
|
|
- parsed_strings.push_back(desc);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
} else if (node_type == "FileDialog" && property_name == "filters") {
|
|
} else if (node_type == "FileDialog" && property_name == "filters") {
|
|
// Extract FileDialog's filters property with values in format "*.png ; PNG Images","*.gd ; GDScript Files".
|
|
// Extract FileDialog's filters property with values in format "*.png ; PNG Images","*.gd ; GDScript Files".
|
|
Vector<String> str_values = property_value;
|
|
Vector<String> str_values = property_value;
|
|
@@ -167,14 +168,32 @@ Error PackedSceneEditorTranslationParserPlugin::parse_file(const String &p_path,
|
|
return OK;
|
|
return OK;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+bool PackedSceneEditorTranslationParserPlugin::match_property(const String &p_property_name, const String &p_node_type) {
|
|
|
|
+ for (const KeyValue<String, Vector<String>> &exception : exception_list) {
|
|
|
|
+ const String &exception_node_type = exception.key;
|
|
|
|
+ if (ClassDB::is_parent_class(p_node_type, exception_node_type)) {
|
|
|
|
+ const Vector<String> &exception_properties = exception.value;
|
|
|
|
+ for (const String &exception_property : exception_properties) {
|
|
|
|
+ if (p_property_name.match(exception_property)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ for (const String &lookup_property : lookup_properties) {
|
|
|
|
+ if (p_property_name.match(lookup_property)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlugin() {
|
|
PackedSceneEditorTranslationParserPlugin::PackedSceneEditorTranslationParserPlugin() {
|
|
// Scene Node's properties containing strings that will be fetched for translation.
|
|
// Scene Node's properties containing strings that will be fetched for translation.
|
|
lookup_properties.insert("text");
|
|
lookup_properties.insert("text");
|
|
- lookup_properties.insert("tooltip_text");
|
|
|
|
- lookup_properties.insert("placeholder_text");
|
|
|
|
- lookup_properties.insert("items");
|
|
|
|
|
|
+ lookup_properties.insert("*_text");
|
|
|
|
+ lookup_properties.insert("popup/*/text");
|
|
lookup_properties.insert("title");
|
|
lookup_properties.insert("title");
|
|
- lookup_properties.insert("dialog_text");
|
|
|
|
lookup_properties.insert("filters");
|
|
lookup_properties.insert("filters");
|
|
lookup_properties.insert("script");
|
|
lookup_properties.insert("script");
|
|
|
|
|