Translations
Overview
Polychromatic uses gettext to localize the application to different languages. The source language is English (United Kingdom) for both the interface and code.
Currently, this application’s translation system is decentralised. The translation is performed offline using POT and PO files and is then added into the project’s version control system.
Prerequisites
You’ll need to install:
- Poedit (or other translation editor)
- The
git
package (or other Git client) - The
intltool
andgettext
package
In order to contribute your changes, you’ll also need:
- An account on GitHub
Before starting, make sure there isn’t an open pull request for your language already. If so, consider leaving a review.
It might be worth checking if there’s been any new, unreleased translations since the last release.
This guide uses Poedit for writing translations and the Terminal for running the
git
command for version control.
Set up the project
-
Fork the polychromatic repository on GitHub.
-
Clone this repository to your computer.
git clone https://github.com/<your username>/polychromatic.git
-
Ensure the translation templates are up-to-date.
./scripts/create-locales.sh
-
(Optional) If you’ve forked this project before, you may need to reset your repository and obtain the latest changes.
git reset HEAD --hard git pull --rebase https://github.com/polychromatic/polychromatic.git master
-
Check the
locales
folder for your language’s locale code:
Translate for a new language
-
Open
locale/polychromatic.pot
and click the [Create New Translation] button. -
Choose your desired language.
-
Start translating!
Tip: Enable the sidebar (View → Show Sidebar) to find translator notes for some strings to assist in determining the context.
-
When finished, save the file to the
locales
directory.Poedit will automatically set the filename to the locale code as appropriate.
The file name should be the locale code. For example, “Spanish (Spain)” would be saved as
es_ES.po
. -
Open
locale/LINGUAS
in your text editor and add the new locale code. -
Open
source/launchers/polychromatic.desktop
in your text editor.Duplicate these lines:
Comment
GenericName
-
Name
(underDesktop Action
)
Append the locale code before the
=
sign inside square brackets[]
and translate the line, like so:GenericName=Device Manager for RGB Lighting GenericName[es]=Administrador de dispositivos para iluminación RGB Comment=Configure connected lighting peripherals Comment[es]=Configurar conectado iluminación periféricos [Desktop Action devices] Name=Configure Devices Name[es]=Configurar dispositivos
-
(Optional) Test your work to check it looks good for end users.
-
When you’re happy with your progress, commit/push your changes.
Translate for an existing language
Assumes the prerequisites have been followed and that your copy of the repository is up-to-date.
-
Ensure the translations are up-to-date with the source code.
./scripts/create-locales.sh
-
Open Poedit and translate!
-
(Optional) You may wish to check these files too:
source/launchers/polychromatic.desktop
-
(Optional) Test your work to check it looks good for end users.
-
When you’re happy with your progress, commit/push your changes.
Test a translation
-
Build the locales:
./scripts/build-locales.sh
-
Run the application from the repository, using the
--locale
parameter to specify the locale code.In order to run the main application from the repository folder, some build dependencies may need to be installed. A message will let you know if something is missing.
./polychromatic-controller-dev --locale <locale> ./polychromatic-tray-applet --locale <locale> ./polychromatic-cli --locale <locale>
Note: Only the user interface is translated. Verbose/debugging output in the Terminal remains in English.
-
When you’re happy with your progress, commit/push your changes.
Commit your changes
-
Open the repository folder in a Terminal. Add the files to Git regarding your locale and create a commit.
git add locale/<locale>.po git add locale/LINGUAS git commit -m "Add translation for <locale>"
Note: Please do not add the
.pot
or.po
files for other languages, which are likely to be modified. -
Push your commit to your fork
(origin)
git push origin master
-
Open a pull request on GitHub. Use the URL below, and replace
GITHUB_USERNAME
with your user name.https://github.com/GITHUB_USERNAME/polychromatic/compare