Help with Translation

Batocera comes in a variety of local languages, and relies on the community to help with the translations. We need you for this!

  1. Download the current translation file (it's a PO text file with all the strings to be translated):
  2. Download the current translation file from this directory. It's an emulationstation.po text file with all the strings to be translated.
  3. Compile your emulationstation2.po file into You can use the Poedit program on your desktop, or online with the Poeditor tool to create the emulationstation2.po and files specific to your language.
  4. Copy your file to /usr/share/locale/<your language code>/LC_MESSAGES/ – for instance /usr/share/locale/pt_BR/LC_MESSAGES/ for Brazilian Portuguese.
  5. Open the command console (SSH terminal) and execute the command batocera-save-overlay to keep your changes upon reboot.
  6. Restart your Batocera. Upon next boot, you will be able to see your translations.
  7. Once you're happy with your translation, you can submit a PR via Github, or send your .po file back to the dev team on the #translations channel of our Discord server. Only the .po files need to be uploaded, not the .mo files.
  1. See what is the current status of your language. You can check on this page to see the percentage of strings that are currently translated for each supported language in the latest stable version of Batocera.
  2. Download the current translation file for your language:
  3. Open the emulationstation2.po or batocera-es-system.po file for your chosen language with either POEdit or an ordinary text editor like Notepad++.
  4. Make your translation edits (your translation should be in the msgstr “” part in the double-quotes (“”)) and save the file.
  5. Copy your .mo file back to /usr/share/locale/<your language code>/LC_MESSAGES/, then run batocera-save-overlay from SSH/terminal.
  6. Restart your Batocera. Upon next boot, you will be able to see your translations.
  7. Get your .po file and put it into the #translations channel on our Discord server, mentioning which language it is for. Only the .po files need to be uploaded, not the .mo files.
  8. That's it.

Thank you for your help!

If there is a line in EmulationStation that does not have a string entry in the PO file, then it can be manually added in with the fake_gettext library:

#define fake_gettext_stringname		pgettext("category", "string")

For example:

#define fake_gettext_flatten_glow			pgettext("game_options", "FLATTEN-GLOW")

Place this into the top of the function which contains the untranslated string and upon next compilation it will be added to all the relevant PO files.

If you are coding something new in Batocera and think that the string to be translated might be a bit ambiguous for translators (remember, they will only see the string in isolation, which might not make sense outside of its context), you can add a comment just for translators to see when they get to that string. In EmulationStation or Batocera's es_features, add the following comment right before the code in which the string appears:

/* TRANSLATION: Short comment that explains the context of the string. */

For example, this is something that has been added to batocera-emulationstation/es-app/src/guis in the source code:

An example of a translator comment in the code.

Generally editing already-existing English strings in the CPP files is discouraged, as it will remove the translation that was made for it (if it exists). However, there may be times when the English string is misspelled or just plain incorrect and needs to be amended, despite it already being translated.

The best way to go about this is to compile batocera-emulationstation, as that will automatically run the xgettext and msgmerge submodules used to generate the emulationstation2.pot and subsequent PO files. You can then use a program like POEdit or just a plain text-editor to restore the translations (old translations are moved to being comments).

Understandably, this is a lot of work, especially with how many languages Batocera supports. So here's a mini-tutorial on how to automate the process (on Windows):

This method does cause corruption when re-imported back into POEdit, so double check that first before re-merging.

  1. Download and install the Find and Replace tool and Notepad++.
  2. Run fnr.exe from the ZIP file.
  3. Set the Dir to the root of the batocera-emulationstation folder.
  4. Add *.po to your File Mask. If you want to also use this tool to edit the string in the CPP itself, you can instead use *.po,*.cpp.
  5. Set Encoding to utf-8. Note that this isn't actually the correct encoding, but it's close enough.
  6. Put in the original string you want to replace into the Find textbox.
  7. Click Find Only to test to see which strings it finds. This is important, especially if also editing CPP files, as it ensures you aren't accidentally overwriting code. If you want to be safe, enclose your find text in double-quotes (“”).
  8. Put in the new string you want to replace it with into the Replace textbox.
  9. Click Replace (the button… not the textbox label).

If you aren't sure of the setup, here's a professional grade pictograph detailing the settings that have been changed from default:

Since you've already cloned batocera-emulationstation, you can just push the PR to merge it. But what's this? You've noticed that after running git diff (as every good developer does before merging a commit I'm sure), every file you've edited now has an additional, invisible character at the beginning that you're sure you didn't insert yourself? That's because Find and Replace is actually not so good with encoding text files so it inserts the Windows 16-bit signature into all the UTF-8 text files at the beginning. This is easy enough to fix.

  1. Open the afflicted text file with Notepad++.
  2. Click EncodingUTF-8. You'll notice that it was originally on “UTF-8-BOM”.
  3. Save the file.
  4. Rinse and repeat for all afflicted text files.

This should get rid of the extra character at the beginning of the text files.

  • help_with_translation.txt
  • Last modified: 6 days ago
  • by atari