3 Translating Librerama to Other Languages
Michael Alexsander edited this page 2 months ago

Translating Librerama to Other Languages

The world is composed of multiple languages, and while English is considered the universal one, not everybody is expected to learn it. Besides, even for those who have, it can just feels better to read stuff in your mother language.

Librerama welcomes any language that it can be translated to. And if you want to bring yours to the game, this guide will help throughout the process.

Note: This tutorial assumes that you know the basics of how to use the Godot Engine's editor, how to clone and make pull requests with Git, and how to edit gettext files (".po" and ".pot"). More information on the gettext can be found in this Wikipedia page.

Generating the POT File

First of all, the POT file needs to be generated to extract the strings that you will translate. This is all done within the Godot editor by following those steps:

  1. Open the script in the path "/tools/generate_translation_pot.gd". Then run the script using the menu or its shortcut:

Place of the "Run" option.

  1. Wait until you regain control of the editor, and a new file has been created in the path "/translations/translation.pot".

  2. Use your gettext editor of choice to create a new PO file in the same directory of the POT file, for example, "/translations/pt_BR.po".

  3. Start translating away! Remember to check the places in the code that those strings are found to get better context.

Adding a Language

After finishing translating all the strings, the game needs to be made aware of the PO file. Open the Project Settings and go to the "Translations" tab, then click in "Add...":

The "Translation" tab.

This will open a file dialog, navigate to the PO file that you made, then add it. The file should now be present on the list.

Now, go to the "Locales Filter" tab, and search for the language that you're adding, then toggle it on:

The "Locales Filter" tab.

Then, add the language's name translated in its own language to the file "/dialogs/settings_dialog/language_names.json", so it will appear as so on the settings dialog. It should be added in alphabetical order with the key being the locale code, and its value being the translated language name (for example: "pt_BR": "Português (Brasil)").

The game should now be able to detect the new language. Play the game and test if you can change to your language in the settings, if you can, success! You should also take the time to see if everything is in place, that no strings are cutoff or don't make sense in the context they're in.

Translating the Metadata

There's still one last step left before we're done! That being translating the metadata files of the project. Those are the files used to give information to OSes that follow freedesktop's AppStream specification (such as GNU/Linux and *BSD) about the application itself.

You will need to know the locale code of the language you're adding. You can find it in this page in Godot's documentation.

The AppData File

The first file is the AppData file, being in the path "/export/freedesktop/page.codeberg.yeldham.Librerama.appdata.xml", which is used by package managers/software centers to show information about the application to users.

The tags that should be translated are:

  • summary.
  • description.
  • And the captions inside screenshots.

They can be translated writing a copy of the tag with the attribute xml:lang with the locale code of the language, for example:

<summary xml:lang="pt_BR">Uma livre coleção de mini jogos de ritmo acelerado</summary>

Remember to place them in alphabetical order with the other translations.

The Desktop File

The second file is the desktop file, located in "/export/freedesktop/page.codeberg.yeldham.Librerama.desktop" is used by the desktop's launcher, to give information about the application to the use and what category to place it.

The properties that should be translated are:

  • GenericName.
  • Comment.

They can be translated writing a copy of the property followed with the locale code between brackets, for example:

GenericName[pt_BR]=Coleção de Mini Jogos

Once again, remember to place them in alphabetical order with the other translations.

Sending the Translation to the Project

Once everything is finally done, the only thing left is sending the translation to the project itself. The recommend way is to open a pull request in the repository to get it merged.

Thank you very much if you decide to contribute!