Skip to content

Translations as a translator with git

trigg edited this page Feb 22, 2024 · 4 revisions

This guide is in sections. Not all of them are needed, depending on the state. If instructions here are unclear please ask in our Discord server.

Steps:

  • Preparing development environment
  • (Optionally) Adding a Language
  • Update translation keys
  • Changing translation string
  • Commit changes
  • Start pull request

alternatively you can contribute translation using Github website directly

Preparing development environment

If you are unfamiliar with Github and git then these steps will help you prepare to submit a translation.

You'll need git sed xgettext and msgmerge as well as bash shell

  1. Fork the repository this link will create a fork of the copy linked to your Github user.
  2. Clone your copy of the repository to your local machine

Adding a Language

If the language you wish to add translations for does not yet exist then you will first need to create a folder to put it in. Firstly work out which 2-letter code is needed. These codes are available Here as ISO-639-1 For these examples I will use Welsh (cy)

from here go into the project directory discover_overlay/locales and create your language directory cy and then LC_MESSAGES, ending up with the empty directory discover_overlay/locales/cy/LC_MESSAGES.

Now create an empty file default.po inside this new directory

mkdir -p discover_overlay/locales/cy/LC_MESSAGES
touch discover_overlay/locales/cy/LC_MESSAGES/default.po

Update translation keys

Grab a terminal and cd to the directory of the project, if you are not already there. Run ./remake_base_pot.sh which will check for any new translatable strings and update all translations so they have any new keys

Changing translation string

After updating keys, the default.po of the language you wish to edit should have a bunch of key and value pairs listed through the text document.

The top of the file has some header data, after which you will see lines starting with msgid followed by lines starting with msgstr. Leave the msgid as is and the msgstr directly afterwards should be changed to the translated string for that word or phrase.

Commit changes

After the file is saved, add the changes to git with git add discover_overlay/locales/cy and then push these back to your github fork with git push

Start pull request

At this point, your github project page should show an option to start a Pull Request in which case go ahead and write a title for the request (along the lines of 'New translations for Welsh' or 'Fixes translations for Welsh') and submit it for review.