remram44 / pybabel-godot

Plugin for Babel to support Godot scene files (.tscn)
Other
14 stars 11 forks source link

Support for (sub-)resources #2

Closed DocSkellington closed 3 years ago

DocSkellington commented 3 years ago

Hello,

For a project, I wanted to store strings in a resource file and be able to translate them. So, I added support for resources and sub-resources. That is, now, .tres (and .res) files should work.

For instance, the field name can be extracted from

[resource]
script = ExtResource(1)
name = "Resource name"

Thank you for your work!

remram44 commented 3 years ago

I actually made this into a different extractor, so you can use a mapping file like:

[python: **.gd]
encoding = utf-8
extract_messages = tr

[godot_scene: **.tscn]
encoding = utf-8

[godot_resource: **.tres]
encoding = utf-8

and do:

pybabel extract -F babelrc -k Label/text -k Resource/fieldname -k tr -o translations.pot .