Skip to content

Commit

Permalink
Update the localization docs
Browse files Browse the repository at this point in the history
  • Loading branch information
westtunger committed Oct 11, 2020
1 parent a2e3083 commit 1773498
Show file tree
Hide file tree
Showing 8 changed files with 301 additions and 288 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ code to disable your changes. Note: currently we don't have an options
menu that could be used to enable inbuilt mods, so this is a bit
difficult at the time of writing.

## Translating the game

You can find the necessary informations about how to translate the game [here](doc/working_with_translations.md).

## Planning Board

The planning board contains all issues and pull requests grouped
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ There are also other useful documents in the [doc](doc) folder not mentioned her
If you have game development skills, you can apply to the team
[here](https://revolutionarygamesstudio.com/application/).

If you'd like to translate the game to your language, you can find the relevant information [here](doc/working_with_translations.md).

The planning board contains all issues and pull requests grouped
by their priority and status. It can be found [here](https://github.com/orgs/Revolutionary-Games/projects/2).

Expand Down
119 changes: 7 additions & 112 deletions doc/setup_instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ installer release. After installing, add the installed folder (where
in command prompt or powershell, it should print 7zip version info and
command line usage.


Linter
------

Expand Down Expand Up @@ -453,6 +454,10 @@ before committing.
When running the script like that it can take a long time to run. See
the pre-commit hook section for how to speed things up.

## Localization tools

The list of tools needed for localization can be found on the [Working with translation page](working_with_translations.md#Required-tools).

Pre-commit hook
---------------

Expand Down Expand Up @@ -486,116 +491,6 @@ build tool option, if it isn't already.
Your locally cloned Thrive version may get messed up from time to time.
[Here are the steps to fix it.](https://wiki.revolutionarygamesstudio.com/wiki/Cleaning_Local_Thrive_Version)

Working with translation
========================

Thrive is using gettext as a localization tool. gettext works by having a
template file (of extension type .pot) and then one translation file for
each language (of extension type .po)

Required tools
--------------

If you are planning to do anything that would require translation, or
simply to translate the game into your locale language you may need
a few more tools.

Note if you are simply planning to add a new localization, Poedit is
enough.

### Python

The tool used to extract strings from the game files is using
[Python](https://www.python.org/downloads).
So if you are planning to add or edit strings into the game, you'll need it.

### Babel and Babel_thrive

Babel and its extension [Babel_thrive](https://github.com/westtunger/pybabel-godot)
are the tools used for extracting strings from the game files.
Just like Python, you'll want to download these if you are planning
to add or edit strings into the game.

### Optional : Poedit

[Poedit](https://poedit.net/) is a free .pot and .po file editor that may
make your life easier when working on translation files.

It is needed to create new .po files without using the command line tools.

Note: Poedit will complain about translation format since it was made to
directly use text as keys. Those can be ignored.


Adding new contents into the game with translation in mind
----------------------------------------------------------

Working with translation in mind will be a bit different than usual, as
it will require a few more steps when working with strings.

### Working in scene files

When working on a scene, once you are done designing it, take note
of all the strings (text, titles, ...) somewhere.

Replace all the strings in your scene with keys (eg. AUTOEVO_POPULATION_CHANGED) and "match" them with your
strings.

(You can use a simple text file writing str => key, or anything else you prefer)

### Working in cs files

Always call TranslationServer.Translate() for strings that should be localized.

Other than that, it is the same principle has for the scene files :
once you are done, write down your strings somewhere And change them in the code into keys.

### Updating the localizations

Once you are done adding content into the game, go into the scripts folder and
run "update_localization.rb". This will extract the strings from the game files,
and also update the .po files if they have been added to it.

The final step is to open en.po in the locale folder (you can use a text editor
or Poedit), search for your keys, and add your strings as translation. Once done,
you can launch the game and make sure everything works as expected.

Translating the game into a new language
----------------------------------------

### Only the first time: create your locale .po file

To create a new .po file for your localization,
you have two choices: using the commands, or Poedit.

#### With commands

Execute the following command in the locale folder :

msginit --no-translator --input=messages.pot --locale=language_code,

#### With Poedit

Open Poedit and use it to generate the .po file by going into the menu
File/New from POT/PO file...

**In both cases, you'll need to enter your language code. You can find a list of all
supported code [in the Godot engine documentation](https://docs.godotengine.org/en/stable/tutorials/i18n/locales.html)**

#### Add your .po file to the update script

To make updating the localization easier, you should add a reference to
the new .po file into update_localization.rb.

Simply open the ruby script into any text editor, and add a new line at the end
of the .po files list as such :

runOpen3Checked 'msgmerge', '--update', '--backup=none', '../locale/**new_po_file_name.po**',
'../locale/messages.pot'

### Translate the texts
### Translating the game

Now that you have the .po file used for the new localization created, you can translate
the game. Simply open the file with Poedit or a simple text editor and translate the texts.
Since we are working with keys, you'll want to open en.po on the side too and use the texts
there as a reference.
You can find information about how to translate the game on the [Working with translation page](working_with_translations.md).
120 changes: 120 additions & 0 deletions doc/working_with_translations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
Working with translation
========================

Thrive is using gettext as a localization tool. gettext works by having a
template file (of extension type .pot) and then one translation file for
each language (of extension type .po)

Required tools
--------------

If you are planning to do anything that would require translation, or
simply to translate the game into your locale language you may need
a few more tools.

Note if you are simply planning to add a new localization, Poedit is
enough.

### Python 3

The tool used to extract strings from the game files is using
[Python 3](https://www.python.org/downloads).
You'll need it if you are planning to add or edit strings in the game.

*Note : Linux users should already have it installed.
You can use the command **python --version** to make sure you have it.
If not, you can use the package manager of your distribution to install the **python3** package.*

### Babel and Babel_thrive

Babel and its extension [Babel_thrive](https://github.com/westtunger/pybabel-godot)
are the tools used for extracting strings from the game files.
Just like Python, you'll want to download these if you are planning
to add or edit strings into the game.

You can quickly install these by using the command **pip install Babel PyBabel-json Babel-Thrive** or **pip3 install Babel PyBabel-json Babel-Thrive**
if you have python installed.

### Optional : Poedit

[Poedit](https://poedit.net/) is a free .pot and .po file editor that may
make your life easier when working on translation files.

It is needed to create new .po files without using the command line tools.

Note: Poedit will complain about translation format since it was made to
directly use text as keys. Those can be ignored.


Adding new contents into the game with translation in mind
----------------------------------------------------------

Working with translation in mind will be a bit different than usual, as
it will require a few more steps when working with strings.

### Working in scene files

When working on a scene, once you are done designing it, take note
of all the strings (text, titles, ...) somewhere.

Replace all the strings in your scene with keys (eg. AUTOEVO_POPULATION_CHANGED) and "match" them with your
strings.

(You can use a simple text file writing str => key, or anything else you prefer)

### Working in cs files

Always call TranslationServer.Translate() for strings that should be localized.

Other than that, it is the same principle has for the scene files :
once you are done, write down your strings somewhere And change them in the code into keys.

### Updating the localizations

Once you are done adding content into the game, go into the scripts folder and
run "update_localization.rb". This will extract the strings from the game files,
and also update the .po files if they have been added to it.

The final step is to open en.po in the locale folder (you can use a text editor
or Poedit), search for your keys, and add your strings as translation. Once done,
you can launch the game and make sure everything works as expected.

Translating the game into a new language
----------------------------------------

### Only the first time: create your locale .po file

To create a new .po file for your localization,
you have two choices: using the commands, or Poedit.

#### With commands

Execute the following command in the locale folder :

msginit --no-translator --input=messages.pot --locale=language_code,

#### With Poedit

Open Poedit and use it to generate the .po file by going into the menu
File/New from POT/PO file...

**In both cases, you'll need to enter your language code. You can find a list of all
supported code [in the Godot engine documentation](https://docs.godotengine.org/en/stable/tutorials/i18n/locales.html)**

#### Add your .po file to the update script

To make updating the localization easier, you should add a reference to
the new .po file into update_localization.rb.

Simply open the ruby script into any text editor, and edit the locale list as such :

**LOCALES = %w[en fr _new-locale_]**

E.g. **LOCALES = %w[en fr jp]**

### Translate the texts

Now that you have the .po file used for the new localization created, you can translate
the game. Simply open the file with Poedit or a simple text editor and translate the texts.
Since we are working with keys, you'll want to open en.po on the side too and use the texts
there as a reference.
Loading

0 comments on commit 1773498

Please sign in to comment.