Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
help_with_translation [2020/05/19 03:13] lbrpdxhelp_with_translation [2023/02/09 02:41] (current) – cleanup/correction atari
Line 1: Line 1:
-=====Help with translation=====+====== Help with Translation ======
  
-Batocera comes in a variety of local languages, and relies on the community to help with the translation+Batocera comes in a variety of local languages, and relies on the community to help with the translationsWe need you for this!
  
-====How can you help?====+===== For translators =====
  
-  - See what is the current status of your language. You can [[https://batocera.org/upgrades/x86_64/beta/last/|check on this page]] to see what's the % of strings that are currently translated for each supported language. +  - First check if someone has already started a translation on [[http://translations.batocera.org/|the translations page]]. Download the two ''*.pot'' files for your language you are going to add translations forThe two files are for EmulationStation-specific strings (ES file) and system-specific options (Options file). If starting a new language, download the ''*.pot'' files from the ''new language'' row in the table. 
-  - Download the current translation file [[https://github.com/batocera-linux/batocera-emulationstation/tree/master/locale/lang|from this directory]]. It's an ''emulationstation.po'' text file with all the strings to be translated. +  - Edit and then compile your translation files. You can use the [[https://poedit.net/|Poedit program]] on your desktop, or online with the [[https://localise.biz/free/poeditor|Poeditor tool]] to create the ''*.po'' and ''emulationstation2.mo'' files specific to your language.<WRAP center round important> 
-  Compile your ''emulationstation2.po'' file into ''emulationstation2.mo''. You can use the [[https://poedit.net/|Poedit program]] on your desktop, or online with the [[https://localise.biz/free/poeditor|Poeditor tool]]. +If using a plain text editor to make your modifications instead, make sure it keeps the Unix end-of-line terminators. 
-  - Connect to your [[access_the_batocera_via_ssh|batocera through SSH]] +</WRAP> 
-  - Copy your ''emulationstation2.mo'' file to ''/usr/share/locale/{your_language_code}/LC_MESSAGES/'' -- for instance ''/usr/share/locale/pt_BR/LC_MESSAGES/emulationstation2.mo'' for Brazilian Portuguese. +  - [[#test_the_translation|Test your translation]] to ensure no lines are cut-off in the UI, special characters appear as intended and most importantly that Batocera does not crash. 
-  - Open command console (Terminaland execute the command ''batocera-save-overlay'' to keep your changes upon reboot +  - Once you're happy with your translation, on the translation page click the region code of your language in the "Code" column and then upload the file to the appropriate "ES file" or "Options file" column on the right side. \\ {{:translation_steps.png|Screenshot showing the step order of clicks, from left to right, top to bottom.}}<WRAP center round tip> 
-  Restart your Batocera  +If it's a brand new language, please contact the dev team on the [[https://discord.gg/ndyUKA5|#translations-files channel of our Discord server]] to get your language added to the table. 
-  Once you're happy with your translationyou can submit PR via Github, or send your .po file back to the dev team on the [[https://discord.gg/ndyUKA5|#translations channel of our Discord server]].+</WRAP> 
 + 
 +Thank you so much for your help! 
 + 
 +<WRAP center round tip> 
 +    * To see a list of the list of missing strings to be translated with their respective line numbers, click on the number in the **ES missing** and **Options missing** columns respectively. 
 +    * If you see a "timer" icon after the file, it means that someone just uploaded a new translation file that hasn't been merged into GitHub yet. 
 +</WRAP> 
 + 
 +==== Test your translation ==== 
 + 
 +  - Merge the ''emulationstation2.po'' and ''batocera-es-system.po'' files in your preferred editor and export the ''emulationstation2.mo'' file from it. 
 +  - Connect to Batocera via [[:winscp|WinSCP]] (or [[:access_the_batocera_via_ssh|via SSH]]). 
 +  - Copy your ''emulationstation2.mo'' file to ''/usr/share/locale/<your language code>/LC_MESSAGES/'' -- for instance ''/usr/share/locale/pt_BR/LC_MESSAGES/emulationstation2.mo'' for Brazilian Portuguese. 
 +  - On a keyboard connected to the Batocera machine, press ''[Alt]'' + ''[F4]'' (or run ''%%batocera-es-swissknife --restart%%'' if in SSHto refresh the language strings in ES. 
 +  - Now explore ES to view all the strings you've translated! 
 + 
 +To keep your changes persistent between reboots, connect via SSH if you haven't already and run ''batocera-save-overlay'' to save the overlay. 
 + 
 +===== For developers ===== 
 + 
 +==== Manually add in a line to be translated ==== 
 + 
 +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: 
 + 
 +<code> 
 +#define fake_gettext_stringname pgettext("category", "string"
 +</code> 
 + 
 +For example: 
 + 
 +<code> 
 +#define fake_gettext_flatten_glow pgettext("game_options", "FLATTEN-GLOW"
 +</code> 
 + 
 +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. 
 + 
 +==== Add a comment in the code for translators ==== 
 + 
 +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: 
 + 
 +<code> 
 +/* TRANSLATION: Short comment that explains the context of the string. */ 
 +</code> 
 + 
 +For example, this is something that has been added to ''batocera-emulationstation/es-app/src/guis'' in the source code: 
 + 
 +{{:translation_string_example.png|An example of a translator comment in the code.}} 
 + 
 +==== Blacklisted words ==== 
 + 
 +What if you want to add in a string that's explicitly not meant to be translatedsuch as proper nountechnical code string or the model name of a retro system? 
 + 
 +Most of these kinds of strings should be automatically picked up and removed by the ''createEsTranslations'' function in [[https://github.com/batocera-linux/batocera.linux/blob/master/package/batocera/emulationstation/batocera-es-system/batocera-es-system.py]], however there might come a case where a word fails to fall into one of its filters. 
 + 
 +Such words can be manually appended to https://github.com/batocera-linux/batocera.linux/blob/master/package/batocera/emulationstation/batocera-es-system/locales/blacklisted-words.txt in the source code. Just add the word on a new line, simple as that. 
 + 
 +==== What if I wanted to edit an English string? ==== 
 + 
 +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 [[https://github.com/batocera-linux/batocera-emulationstation/|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): 
 + 
 +<WRAP center round alert> 
 +This method does cause corruption when re-imported back into POEdit, so double check that first before re-merging. 
 +</WRAP> 
 + 
 +  - Download and install the [[http://findandreplace.io/download|Find and Replace tool]] and [[http://notepad-plus-plus.org/downloads/|Notepad++]]. 
 +  - Run ''fnr.exe'' from the ZIP file. 
 +  - Set the **Dir** to the root of the ''batocera-emulationstation'' folder. 
 +  - 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''
 +  - Set **Encoding** to ''utf-8''. Note that this isn't actually the correct encoding, but it's close enough. 
 +  - Put in the original string you want to replace into the **Find** textbox. 
 +  - 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 (""). 
 +  - Put in the new string you want to replace it with into the **Replace** textbox. 
 +  - 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: 
 + 
 +{{:wiki:how_to_replace_strings.png?direct|}} 
 + 
 +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. 
 + 
 +  - Open the afflicted text file with Notepad++. 
 +  - Click **Encoding** -> **UTF-8**. You'll notice that it was originally on "UTF-8-BOM"
 +  - Save the file. 
 +  - Rinse and repeat for all afflicted text files. 
 + 
 +This should get rid of the extra character at the beginning of the text files.
  
-Thank you for your help! 
  • help_with_translation.1589850804.txt.gz
  • Last modified: 4 years ago
  • by lbrpdx