Skip to content

Translation scripts #301

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

Merged
merged 4 commits into from
Nov 6, 2024
Merged

Translation scripts #301

merged 4 commits into from
Nov 6, 2024

Conversation

dbnicholson
Copy link
Member

CLI script for updating translations. The regenerate-pot.gd script is pretty nasty since it has to with for the editor before poking at the UI. The others are pretty straightforward. I wasn't sure if we wanted to add GitHub workflows for these or not.

https://phabricator.endlessm.com/T35705

@dbnicholson dbnicholson requested a review from wjt November 4, 2024 19:17
Copy link
Contributor

@starnight starnight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this depend on Godot 4.4?

Because, scripts/regenerate-pot.sh shows errors with Godot 4.3:

Godot Engine v4.3.stable.flathub.77dcf97d8 - https://godotengine.org

ERROR:  Config File "user://gut_temp_directory/gut_editor_config.json" does not exist.
Updating BlockCode POT file res://addons/block_code/locale/godot_block_coding.pot
WARNING: 10 RIDs of type "Canvas" were leaked.
     at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2485)
WARNING: 114 RIDs of type "CanvasItem" were leaked.
     at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2485)
ERROR: 10 RID allocations of type 'N16RendererViewport8ViewportE' were leaked at exit.
ERROR: 56 RID allocations of type 'PN13RendererDummy14TextureStorage12DummyTextureE' were leaked at exit.
ERROR: 1 RID allocations of type 'N17RendererSceneCull8ScenarioE' were leaked at exit.
ERROR: 214 RID allocations of type 'PN18TextServerAdvanced22ShapedTextDataAdvancedE' were leaked at exit.
ERROR: 18 RID allocations of type 'PN18TextServerAdvanced12FontAdvancedE' were leaked at exit.
ERROR: 1 RID allocations of type 'PN18TextServerAdvanced27FontAdvancedLinkedVariationE' were leaked at exit.
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2284)
ERROR: 13 resources still in use at exit (run with --verbose for details).
   at: clear (core/io/resource.cpp:604)

@dbnicholson
Copy link
Member Author

Does this depend on Godot 4.4?

Because, scripts/regenerate-pot.sh shows errors with Godot 4.3:

Godot Engine v4.3.stable.flathub.77dcf97d8 - https://godotengine.org

ERROR:  Config File "user://gut_temp_directory/gut_editor_config.json" does not exist.
Updating BlockCode POT file res://addons/block_code/locale/godot_block_coding.pot
WARNING: 10 RIDs of type "Canvas" were leaked.
     at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2485)
WARNING: 114 RIDs of type "CanvasItem" were leaked.
     at: _free_rids (servers/rendering/renderer_canvas_cull.cpp:2485)
ERROR: 10 RID allocations of type 'N16RendererViewport8ViewportE' were leaked at exit.
ERROR: 56 RID allocations of type 'PN13RendererDummy14TextureStorage12DummyTextureE' were leaked at exit.
ERROR: 1 RID allocations of type 'N17RendererSceneCull8ScenarioE' were leaked at exit.
ERROR: 214 RID allocations of type 'PN18TextServerAdvanced22ShapedTextDataAdvancedE' were leaked at exit.
ERROR: 18 RID allocations of type 'PN18TextServerAdvanced12FontAdvancedE' were leaked at exit.
ERROR: 1 RID allocations of type 'PN18TextServerAdvanced27FontAdvancedLinkedVariationE' were leaked at exit.
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2284)
ERROR: 13 resources still in use at exit (run with --verbose for details).
   at: clear (core/io/resource.cpp:604)

No it doesn't, but yes there are a ton of errors regardless of what version you use. Until godotengine/godot-proposals#10986 is available, the method of updating the POT file is pretty nasty. Let me see if I can figure out how to suppress the leak errors since we don't actually care about them.

To ease running Godot from the command line, provide a wrapper script
that looks for common Godot executables. As an escape hatch, the `GODOT`
environment variable can be used to set exactly how Godot should be
executed. This is very Linux-centric with only `godot` or the Godot
Flatpak supported, but it can be extended as needed.
This can be used to execute TxUtils.regenerate_pot_file() from the CLI.
The GDScript is a SceneTree script passed via Godot's --script CLI
option. The shell script is a wrapper to execute Godot with all the
necessary options.

Since TxUtils.regenerate_pot_file() works by using the editor's
Localization panel, the script has to be run with --editor. That causes
a bunch of leaks that we can't do anything about. The script tries to
soothe the user about the pile of warnings and errors at the end.
This can be used to execute TxUtils.update_pot_files() from the CLI. The
GDScript is a SceneTree script passed via Godot's --script CLI option.
The shell script is a wrapper to execute Godot with all the necessary
options. Unlike TxUtils.regenerate_pot(), the editor isn't required, so
everything can happen from _init().
Since the other components can be scripted, we might as well add a
wrapper script to merge new translation strings into PO files.
@dbnicholson
Copy link
Member Author

I couldn't figure out any way to silence the warnings and errors about the leaks besides using /dev/null, so I added a message in the output to ignore them.

@wjt wjt merged commit 79a4463 into main Nov 6, 2024
3 checks passed
@wjt wjt deleted the automate-translation branch November 6, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants