You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tutorials/i18n/internationalizing_games.rst
+38Lines changed: 38 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -58,6 +58,44 @@ Select the resource to be remapped then add some alternatives for each locale.
58
58
the current language, making it ideal for things like multiplayer chat where
59
59
the text language may not match the client's language.
60
60
61
+
Automatically setting a language
62
+
--------------------------------
63
+
It is recommended to default to the user's preferred language which can be obtained via :ref:`OS.get_locale_language() <class_OS_method_get_locale_language>`.
64
+
If your game is not available in that language, it will fall back to the :ref:`Fallback <class_ProjectSettings_property_internationalization/locale/fallback>`
65
+
in **Project Settings > Internationalization > Locale**, or to ``en`` if empty.
66
+
Nevertheless letting players change the language in game is recommended for various reasons (e.g. translation quality or player preference).
67
+
68
+
.. tabs::
69
+
.. code-tab:: gdscript
70
+
71
+
var language = "automatic"
72
+
# Load here language from the user settings file
73
+
if language == "automatic":
74
+
var preferred_language = OS.get_locale_language()
75
+
TranslationServer.set_locale(preferred_language)
76
+
else:
77
+
TranslationServer.set_locale(language)
78
+
79
+
Locale vs. language
80
+
-------------------
81
+
A :ref:`locale <doc_locales>` is commonly a combination of a language with a region or country, but can also contain information like a script or a variant.
82
+
83
+
Examples:
84
+
85
+
- ``en``: English language
86
+
- ``en_GB``: English in Great Britain / British English
87
+
- ``en_US``: English in the USA / American English
88
+
- ``en_DE``: English in Germany
89
+
90
+
Indie games generally only need to care about language, but read on for more information.
91
+
92
+
Why locales exist can be illustrated through the USA and Great Britain. Both speak the same language (English), yet differ in many aspects:
93
+
- Spelling: E.g. gray (USA), grey (GB)
94
+
- Use of words: E.g. eggplant (USA), aubergine (GB)
95
+
- Units or currencies: E.g. feet/inches (USA), metres/cm (GB)
96
+
97
+
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.
0 commit comments