Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Add explanation for locales and automatic language setting #10008

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tutorials/i18n/internationalizing_games.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,41 @@ Select the resource to be remapped then add some alternatives for each locale.
the current language, making it ideal for things like multiplayer chat where
the text language may not match the client's language.

Automatically setting a language
--------------------------------
It is recommended to default to the user's preferred language which can be obtained via :ref:`OS.get_locale_language() <class_OS_public_method_get_locale_language>`. If your game is not available in that language, it will fallback to the one in **Project settings > General > Internationalization > Locale (Advanced settings)** (if empty `en` for English will be used which is recommended).
stephanbogner marked this conversation as resolved.
Show resolved Hide resolved
Nevertheless letting players change the language in game is recommended for various reasons (e.g. translation quality or player preference).

.. tabs::
.. code-tab:: gdscript
var language = "automatic"
stephanbogner marked this conversation as resolved.
Show resolved Hide resolved
# Load here language from the user settings file
if language == "automatic":
var preferred_language = OS.get_locale_language()
TranslationServer.set_locale(preferred_language)
else:
TranslationServer.set_locale(language)

Locale vs. language
-------------------
A Locale is commonly a combination of a language with a region or country but can also contain more information like scripts.

Examples:

- `en`: English language
- `en_GB`: English in Great Britain / British English
- `en_US`: Enginsh in the USA / American English
stephanbogner marked this conversation as resolved.
Show resolved Hide resolved
- `en_DE`: English in Germany

Indie games generally only need to care about language, but read on for more information.

Why locales exist can be illustrated through the USA and Great Britain. Both speak the same language (English), yet differ in many aspects:
- Spelling: E.g. Gray (USA), grey (GB)
stephanbogner marked this conversation as resolved.
Show resolved Hide resolved
- Use of words: E.g. eggplant (USA), aubergine (GB)
- Units or currencies: E.g. feet/inches (USA), meter/cm (GB)
stephanbogner marked this conversation as resolved.
Show resolved Hide resolved

It can get more complex however. Imagine you offer different content in Europe and in China (e.g. in an MMO). You will need to translate each of those content variations into many languages and store and load them accordingly.

Converting keys to text
-----------------------

Expand Down
Loading