Skip to content

Commit

Permalink
Improved the working with translations documentation a bit (Revolutio…
Browse files Browse the repository at this point in the history
…nary-Games#3781)

* Improved the working with translations documentation a bit

fixed an incorrect info on running the extraction, fixed a typo and added a bit more info for clarity about scene files

* Fixed up outdated references to the formatting script in style_guide.md

* Might as well update the submodule in my open PR as well
  • Loading branch information
hhyyrylainen authored Sep 15, 2022
1 parent 1a2c2f5 commit ed18305
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
13 changes: 4 additions & 9 deletions doc/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,10 @@ Code style rules
fail.

- Due to StyleCop not having rules for everything, there are
additional rules implemented by `check_formatting.rb` which you
should run before committing to make sure there are no issues in
your code.

- For faster rebuilding have a look at the scripts in
scripts/fast_build. With the `toggle_analysis_mode.rb` script it is
possible to turn off the analysis so that small tweaks to the game
are faster to test. Next time you run the formatting script the
checks should get turned back on.
additional rules implemented by a custom script (`dotnet run
--project Scripts check`) which you should run before committing to
make sure there are no issues in your code. This script can be
enabled to run automatically with pre-commit.

- All classes and their public and protected members should be
documented by XML comments. If the function's purpose is clear from
Expand Down
19 changes: 13 additions & 6 deletions doc/working_with_translations.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ will make the translation system skip it.
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.
once you are done, write down your strings somewhere and change them in the code into keys.

Note that due to the way the text extraction works, only string
literals work in the `Translate` call, using variables or string
concatenation, won't extract things properly. For example this is the
concatenation won't extract things properly. For example this is the
correct usage: `TranslationServer.Translate("A_TRANSLATION_KEY");`

The translation keys need to be named all uppercase with underscores
Expand All @@ -78,10 +78,11 @@ translation key like `PLAY_MUSIC`.

### Updating the localizations

Once you are done adding content into the game, go into the scripts
folder and run `dotnet run --project Scripts -- localization`. This
will extract the strings from the game files, and also update the .po
files if the template (.pot) has changed.
Once you are done adding content into the game, open the Thrive folder
in terminal / command prompt and run `dotnet run --project Scripts --
localization`. This will extract the translation keys from the game
files, and also update the .po files if the template (.pot) has
changed.

gettext automatically "guesses" some text which might be right when a new translation
key appears in a file. This is fine as the texts are marked as needing changes (fuzzy),
Expand Down Expand Up @@ -130,6 +131,12 @@ place with complicated logic where the simplest solution is to pass all text thr
translation system so that the things that need translating get translated and other strings
just pass through.

In scene files any text that has a translated version will get
automatically translated. So for scenes it is enough to replace the
text properties with translation keys, run the text extraction, and
add translations for the new keys. Then Godot will automatically when
running use the translations for that scene file.

Our custom extensions to the Godot translation system consist of two classes:
`LocalizedString` and `LocalizedStringBuilder`. `LocalizedString` is a special
type of string that allows passing in the translation key to it. For example:
Expand Down

0 comments on commit ed18305

Please sign in to comment.