Zylann / godot_heightmap_plugin

HeightMap terrain for Godot implemented in GDScript
Other
1.72k stars 159 forks source link

Translating the plugin #359

Open ElsAr4e opened 1 year ago

ElsAr4e commented 1 year ago

I would like to help to translate this plugin.

Is that possible and if yes how can I help?

If it's possible can the plugin detect which editor language Godot uses and automatically uses the language - for example French, Hungarian, etc ?

MGilleronFJ commented 1 year ago

I thought about that, it would be great to have, but not sure how well it would work, I haven't seen translated plugins before. The plugin would have to come with a CSV file and somehow register it into Godot's translation server resource, with some code. It needs investigation.

In the code I very often use the "message {1}, {2}".format([a, b]) pattern to format strings. This makes the string free of interleaved code, allowing to wrap it into the tr method: tr("message {1}, {2}").format([a, b]) (see docs).

A lot of text is inside the tscn UI scenes though, I wonder if the Godot Editor can translate these automatically?

Dragoncraft89 commented 1 year ago

Just leaving my 2 cents here, as I have done some translation in godot before:

Game Translation in Godot is handled via the TranslationServer object. You can add a translation resource via TranslationServer.add_translation(...). The translation resource can be loaded as usual with load(...) on a .translation file or a .po file (gettext format). Afterwards tr(...) can be used to translate the string.

You'd have to do this once in your plugin startup code and (should) remove it with TranslationServer.remove_translation(...) when the plugin is unloaded. Keep in mind that the translation will be applied to the whole godot editor, therefore you should try to avoid name clashes of your message IDs

Regarding .tscn scenes, UI nodes automatically translate their strings. If you find a case where this doesn't work, then this is most likely a bug in Godot.

The most annoying part would probably be setting up a translation platform. I'd recommend Weblate, they offer free hosting for open source projects. Although the registration process for your free hosting may take a while (it took about a month for my last project). Furthermore Weblate doesn't support the same CSV format as Godot does, so if you want to use Weblate I'd recommend sticking to the gettext format (.po files)