Skip to content

Language versions

Krzysztof Pantak edited this page Jul 8, 2023 · 4 revisions

Translation guide

AnyGrabber was created in English language and translated into Polish. It is easy to translate into other languages. The following page, after a brief introduction, will show you how to translate it into the language of your choice.

The programs' translation is stored in .pot and .po files. The .pot file is generated based on translation strings found inside the code. Those are strings that start with the _ mark (for example _("Language")). Those strings can then be automatically parsed to update the .pot file as a base for language translations. Translation into other languages involves adding a single line of code to create a new menu entry and doing the actual translation using a simple interface provided by the Poedit program. We then add appropriate translations and save them into a .po and .mo files. The program automatically recognizes them, swapping the translation strings that start with _ with the actual translations.

Getting started

The following guide assumes that you know how to clone the repo to your computer. If you need guidance on how to do this follow the official guide How to clone GitHub repository

  1. Download the free version of the open-source program called POEDIT. Install and run the program. After the successful installation, you should be greeted with a screen similar to the one shown below:

Poedit Welcome screen

  1. Choose Browse files option

  2. Locate the AnyGrabber folder, go to the locale directory, and open the Main.pot file. Your screen should look similar to this one: Main.pot file contents shown by Poedit

  3. If you made any changes to _ strings inside the code, you can use the Update from code option to load them into the program. Updating .pot file from code

  4. Now you can create a new translation from this pot file by clicking the Create a new translation button that should be located on the bottom part of the window

Adding a new translation

  1. Choose a new language that you would like to translate into, for example German.

  2. Add the translations for texts - you can use the suggestions on the right side of a window Adding the translations

  3. When done, click file menu and select save as.

  4. Go to AnyGrabber locale folder and create a new folder with desired locale name - for example de-DE for German.

Creating a new directory for translation

  1. Inside de-DE directory create another folder called LC_MESSAGES.

  2. Save the file as Main.po

Saving the new file

  1. Main.mo file should be generated automatically. Refer to folder structure for other languages if you got lost on directory structure for new translation.

  2. Open the locale_utils.py file that is located inside utils folder in AnyGrabbers' main directory

  3. Add a language mapping for your chosen language - for example `"de-DE": _("German")"

Adding new mapping

  1. Done - your new translation is ready - or is it?

Saving the new file

  1. As you might have noticed - the new translation is missing the new _("German") that we added to the mappings list. Therefore we need to update our Main.pot file from code. Open this file and refer to step 4 - click the update from code button.

  2. Your new translation string should be present on the list. Click the save button.

  3. Click the open button and go to de-DE folder, then LC_MESSAGES and open Main.po.

  4. When new Poedit window opens, go to Translation menu and choose Update from POT file.

Updating .po from .pot

  1. Go back to locale folder inside AnyGrabber root. Select Main.pot file.

  2. Sources and translations list should reflect the newest changes to source file, update the translation for German, and click the save button.

Adding the new translation

  1. Done - your new translation is complete.

Window with new translation

Clone this wiki locally