Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localization POT generation does not regognize text on instanced nodes. #74194

Closed
Okxa opened this issue Mar 1, 2023 · 2 comments · Fixed by #89286
Closed

Localization POT generation does not regognize text on instanced nodes. #74194

Okxa opened this issue Mar 1, 2023 · 2 comments · Fixed by #89286

Comments

@Okxa
Copy link

Okxa commented Mar 1, 2023

Godot version

v4.0.stable.official [92bee43]

System information

Arch Linux

Issue description

Localization POT generation does not regognize text on instanced nodes.

Steps to reproduce

  1. Create a 2D main scene
  2. Create a scene with a button as the single node
  3. Add the button scene as a instance to the main scene and edit the button instances text
  4. Add a button node (not the instance) to the main scene and edit the buttons text
  5. Go to Project Settings -> Localization -> POT generation, Add the main scene and generate POT file
  6. observe the POT file and see there is no localization ID for the instanced buttons text

Minimal reproduction project

localization_instances.zip

@Okxa
Copy link
Author

Okxa commented Mar 2, 2023

Issue might be that instanced button has no type when queried with SceneState.get_node_type()

The parser checks with the type if the node is translatable

for (int i = 0; i < state->get_node_count(); i++) {
String node_type = state->get_node_type(i);
if (!ClassDB::is_parent_class(node_type, "Control") && !ClassDB::is_parent_class(node_type, "Window")) {
continue;
}

Tested if instances behave differently with the checks used in the parser (only in editor though):

func _ready():
    var state = ResourceLoader.load("res://main.tscn").get_state()
    var nodecount = state.get_node_count()
    for i in range(0, nodecount):
        var nodetype = state.get_node_type(i)
        print(state.get_node_name(i), ", type: ", nodetype, ", child of Control: ", ClassDB.is_parent_class(nodetype, "Control"), ", child of Window: ", ClassDB.is_parent_class(nodetype, "Window"))
        var propcount = state.get_node_property_count(i)
        for j in range(0, propcount):
            print(state.get_node_property_name(i, j), " ", state.get_node_property_value(i, j))

outputs:

...
Button, type: Button, child of Control: true, child of Window: false
offset_right 8
offset_bottom 8
text NORMAL_BTN
btn_instance, type: , child of Control: false, child of Window: false
offset_top 45
offset_bottom 188
text INSTANCED_BTN

@brunolucena
Copy link

I'm also facing this issue. Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants