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

POT Generation not detecting exported variables #90053

Closed
cashew-olddew opened this issue Mar 30, 2024 · 4 comments
Closed

POT Generation not detecting exported variables #90053

cashew-olddew opened this issue Mar 30, 2024 · 4 comments

Comments

@cashew-olddew
Copy link

Tested versions

  • Reproductible in 4.2.stable

System information

Windows 10 - Godot v4.2.1.stable Forward+

Issue description

Generating a POT file from Project > Project Settings > Localization > POT Generation creates a template file which only includes text written for built-in nodes.

I would expect that any node which has an exported text property to be considered for POT Generation.

Steps to reproduce

  1. Create a Label and set its text to 'EXAMPLE'
  2. Create a node2D which has a script that exports a String variable: @export var text: String = "". Instantiate that node and set its exported variable text to 'OTHER_EXAMPLE'
  3. Go to Project > Project Settings > Localization > POT Generation. Add the main scene and click Generate POT
  4. The generated template does not contain 'OTHER_EXAMPLE':
# LANGUAGE translation for LocalizationMRP for the following files:
# res://main.tscn
#
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: LocalizationMRP\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"

#: main.tscn
msgid "EXAMPLE"
msgstr ""

Minimal reproduction project (MRP)

LocalizationMRP.zip

@dalexeev
Copy link
Member

  • Reproductible in 4.2.stable

Can't reproduce in 4.3 dev (current master). Probably fixed by #89286.

template.pot
# LANGUAGE translation for LocalizationMRP for the following files:
# res://main.tscn
# res://Node2D.gd
#
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: LocalizationMRP\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"

#: main.tscn
msgid "EXAMPLE"
msgstr ""

#: main.tscn
msgid "OTHER_EXAMPLE"
msgstr ""

@Kiisu-Master
Copy link
Contributor

Kiisu-Master commented Mar 31, 2024

I think the problem in the MRP was fixed when the node type check was removed by #87530. Before it would only include Control or Window nodes.

My PR fixed parsing of instanced scenes, and it made the included properties more dynamic. It will try to include all properties with a name that ends with _text.

// Scene Node's properties containing strings that will be fetched for translation.
lookup_properties.insert("text");
lookup_properties.insert("*_text");
lookup_properties.insert("popup/*/text");
lookup_properties.insert("title");
lookup_properties.insert("filters");
lookup_properties.insert("script");
// Exception list (to prevent false positives).
exception_list.insert("LineEdit", { "text" });
exception_list.insert("TextEdit", { "text" });
exception_list.insert("CodeEdit", { "text" });

This issue shouldn't be closed yet. Included and excluded node types and properties should be configurable to the user so they can decide themselves what should be included. I already have wanted to implement this, as i said in my PR, but im missing the motivation to figure out how to add project settings and start compiling Godot again (it takes like 3 hours).

@AThousandShips
Copy link
Member

Included and excluded node types and properties should be configurable to the user so they can decide themselves what should be included.

This sounds like something that should be a proposal, it's far outside the scope of this report

@AThousandShips
Copy link
Member

Closing as fixed, please open a proposal for any additional features

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

No branches or pull requests

4 participants