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
+60-41Lines changed: 60 additions & 41 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,11 +6,10 @@ Internationalizing games
6
6
Introduction
7
7
------------
8
8
9
-
While indie or niche games usually
10
-
do not need localization, games targeting a more massive market
11
-
often require localization. Godot offers many tools to make this process
12
-
more straightforward, so this tutorial is more like a collection of
13
-
tips and tricks.
9
+
While indie or niche games usually do not need localization, games targeting
10
+
a more massive market often require localization. Godot offers many tools to
11
+
make this process more straightforward, so this tutorial is more like a
12
+
collection of tips and tricks.
14
13
15
14
Localization is usually done by specific studios hired for the job. Despite the
16
15
huge amount of software and file formats available for this, the most common way
@@ -60,10 +59,14 @@ Select the resource to be remapped then add some alternatives for each locale.
60
59
61
60
Automatically setting a language
62
61
--------------------------------
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>`
62
+
63
+
It is recommended to default to the user's preferred language which can be
64
+
obtained via :ref:`OS.get_locale_language() <class_OS_method_get_locale_language>`.
65
+
If your game is not available in that language, it will fall back to the
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).
68
+
Nevertheless, letting players change the language in game is recommended for
69
+
various reasons (e.g. translation quality or player preference).
67
70
68
71
.. tabs::
69
72
.. code-tab:: gdscript
@@ -78,7 +81,9 @@ Nevertheless letting players change the language in game is recommended for vari
78
81
79
82
Locale vs. language
80
83
-------------------
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.
84
+
85
+
A :ref:`locale <doc_locales>` is commonly a combination of a language with a
86
+
region or country, but can also contain information like a script or a variant.
82
87
83
88
Examples:
84
89
@@ -87,21 +92,26 @@ Examples:
87
92
- ``en_US``: English in the USA / American English
88
93
- ``en_DE``: English in Germany
89
94
90
-
Indie games generally only need to care about language, but read on for more information.
95
+
Indie games generally only need to care about language, but read on for more
96
+
information.
97
+
98
+
Why locales exist can be illustrated through the USA and Great Britain.
99
+
Both speak the same language (English), yet differ in many aspects:
91
100
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)
101
+
- Spelling: e.g. gray (USA), grey (GB)
102
+
- Use of words: e.g. eggplant (USA), aubergine (GB)
103
+
- Units or currencies: e.g. feet/inches (USA), metres/cm (GB)
96
104
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.
105
+
It can get more complex however. Imagine you offer different content in Europe
106
+
and in China (e.g. in an MMO). You will need to translate each of those content
107
+
variations into many languages and store and load them accordingly.
98
108
99
109
Converting keys to text
100
110
-----------------------
101
111
102
112
Some controls, such as :ref:`Button <class_Button>` and :ref:`Label <class_Label>`,
103
113
will automatically fetch a translation if their text matches a translation key.
104
-
For example, if a label's text is "MAIN_SCREEN_GREETING1" and that key exists
114
+
For example, if a label's text is ``MAIN_SCREEN_GREETING1`` and that key exists
105
115
in the current translation, then the text will automatically be translated.
106
116
107
117
This automatic translation behavior may be undesirable in certain cases. For
@@ -160,6 +170,8 @@ allow translators to choose the *order* in which placeholders appear:
160
170
# Additionally, this form gives more context for translators to work with.
161
171
message.text = tr("{character} picked up the {weapon}").format({character = "Ogre", weapon = "Sword"})
Providing pluralized translations is only supported with
232
-
:ref:`doc_localization_using_gettext`, not CSV.
233
-
234
243
Making controls resizable
235
244
-------------------------
236
245
@@ -277,7 +286,7 @@ the current language can also be changed at runtime.
277
286
278
287
.. _doc_internationalizing_games_bidi:
279
288
280
-
Bidirectional text and UI Mirroring
289
+
Bidirectional text and UI mirroring
281
290
-----------------------------------
282
291
283
292
Arabic and Hebrew are written from right to left (except for the numbers and Latin
@@ -289,18 +298,27 @@ usually need to change anything or have any knowledge of the specific writing sy
289
298
290
299
For RTL languages, Godot will automatically do the following changes to the UI:
291
300
292
-
- Mirrors left/right anchors and margins.
293
-
- Swaps left and right text alignment.
294
-
- Mirrors horizontal order of the child controls in the containers, and items in Tree/ItemList controls.
295
-
- Uses mirrored order of the internal control elements (e.g. OptionButton dropdown button, checkbox alignment, List column order, Tree item icons and connecting line alignment, e.t.c.), in some cases mirrored controls use separate theme styles.
296
-
- Coordinate system is not mirrored, and non-UI nodes (sprites, e.t.c) are not affected.
297
-
298
-
It is possible to override text and control layout direction by using the following control properties:
299
-
300
-
- ``text_direction``, sets the base text direction. When set to "auto", direction depends on the first strong directional character in the text according to the Unicode Bidirectional Algorithm,
301
-
- ``language``, overrides current project locale.
302
-
- ``structured_text_bidi_override`` property and ``_structured_text_parser`` callback, enables special handling for structured text.
303
-
- ``layout_direction``, overrides control mirroring.
301
+
- Mirrors left/right anchors and margins.
302
+
- Swaps left and right text alignment.
303
+
- Mirrors horizontal order of the child controls in the containers, and items in
304
+
Tree/ItemList controls.
305
+
- Uses mirrored order of the internal control elements (e.g., OptionButton
306
+
dropdown button, CheckBox/CheckButton alignment, List column order, TreeItem icons
307
+
and connecting line alignment). In some cases, mirrored controls
308
+
use separate theme styles.
309
+
- Coordinate system is **not** mirrored.
310
+
- Non-UI nodes (sprites, etc.) are **not** affected.
311
+
312
+
It is possible to override text and control layout direction by using
313
+
the following control properties:
314
+
315
+
- ``text_direction``, sets the base text direction. When set to "auto",
316
+
the direction depends on the first strong directional character in the text
317
+
according to the Unicode Bidirectional Algorithm.
318
+
- ``language``, overrides the current project locale.
319
+
- The ``structured_text_bidi_override`` property and ``_structured_text_parser``
320
+
callback, enable special handling for structured text.
321
+
- ``layout_direction``, overrides control mirroring.
304
322
305
323
.. image:: img/ui_mirror.png
306
324
@@ -317,7 +335,8 @@ word and line breaking require more than rules over character sequences.
317
335
Godot includes ICU rule and dictionary-based break iterator data, but this data
318
336
is not included in exported projects by default.
319
337
320
-
To include it, go to **Project → Project Settings**, enable **Internationalization → Locale → Include Text Server Data**,
338
+
To include it, go to **Project → Project Settings**, enable
339
+
**Internationalization → Locale → Include Text Server Data**,
321
340
then export the project. Break iterator data is about 4 MB in size.
322
341
323
342
Structured text BiDi override
@@ -359,19 +378,19 @@ Testing translations
359
378
You may want to test a project's translation before releasing it. Godot provides three ways
360
379
to do this.
361
380
362
-
First, in the Project Settings, under :menu:`Internationalization > Locale` (with advanced settings enabled), there is a **Test**
363
-
property. Set this property to the locale code of the language you want to test. Godot will
364
-
run the project with that locale when the project is run (either from the editor or when
365
-
exported).
381
+
First, in the Project Settings, under :menu:`Internationalization > Locale`
382
+
(with advanced settings enabled), there is a **Test** property. Set this property
383
+
to the locale code of the language you want to test. Godot will run the project
384
+
with that locale when the project is run (either from the editor or when exported).
366
385
367
386
.. image:: img/locale_test.webp
368
387
369
388
Keep in mind that since this is a project setting, it will show up in version control when
370
389
it is set to a non-empty value. Therefore, it should be set back to an empty value before
371
390
committing changes to version control.
372
391
373
-
Second, from within the editor go to the top bar and click on :button:`View` on the top bar, then go down to
374
-
:ui:`Preview Translation` and select the language you want to preview.
392
+
Second, from within the editor go to the top bar and click on :button:`View` on the top bar,
393
+
then go down to :ui:`Preview Translation` and select the language you want to preview.
0 commit comments