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: docs/Virtual-Anatomy-(Unreal-Engine)/Localization.md
+42-21Lines changed: 42 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,48 +4,69 @@ weight: 1
4
4
5
5
# Localization
6
6
7
-
The localization feature of the application was done through Unreal Engine's integrated localization. Here we will walk you through the process and how to update localization if needed.
7
+
The localization feature of the application was done through Unreal Engine's integrated localization. This section provides a step-by-step guide on how to update localization when needed.
First we gather text present in all game files. For this we tick the "Gather from Packages" checkbox and specify where the engine should look for text to gather. To specify, we make use of the path wildcards option and tell the engine to look through everything contained in the `Content` directory which contains all our files for the application.
13
+
First and foremost, for all (new) text blocks you want to translate, you need to specify if they should be localized. To do this, open your Widget Blueprint and switch to `Designer` mode [1.] (or any Unreal Engine object, like Data Table, containing a text field). Select any text block that you want to localize [2.]. Then, in the `Details` panel, click a flag icon [3.] make sure the `Localize` option is checked [4.].
14
14
15
-
After this we can add new cultures through the `Localization dashboard`. We then set the native culture for the application, which is English in this case. And finally we gather the text using the `Gather Text` button in the dashboard.
In the translation editor we quite simply manually translate the words we need.
21
+
For text blocks that are defined in C++ code, you need to use the `LOCTEXT` or `NSLOCTEXT` macro. These macro allow you to define a text block that can be localized. Here is an example of how to use `NSLOCTEXT`:
22
22
23
-
**Note**
23
+
```cpp
24
+
NSLOCTEXT([Namespace], [Key], [Source String]);
25
+
e.g. NSLOCTEXT("SomeNamespace", "SomeKey", "This is the text to be localized");
26
+
```
24
27
25
-
It is possible to use third party services to translate, using `Portable Object` files. As these third party services are usually paid we refrained from using them, considering the scale of the application.
28
+
The only difference between `NSLOCTEXT` and `LOCTEXT` is that the former allows you to specify a namespace, which might help organize your localization strings better.
Once we have the necessary words translated, the process is simple:
32
+
Make sure not to assign those macros to string variables since that would prevent the Unreal Engine from recognizing them as localizable text. They should be used/reffered in a `FText` variable.
30
33
31
-
`save > gather text > compile text`
34
+
## Localization configuration and modification
32
35
33
-
# Important
36
+
If you are ready to start localizing your application, you can do so through the `Localization Dashboard` which can be found in the `Tools` top menu. This dashboard provides a comprehensive interface for managing localization settings, gathering text, and translating content.
34
37
35
-
For all text blocks we want to translate, we need to specify if they should be localized. For this purpose we simply open the UMG, select the text we want to localize and in the `Details` panel we check the `localize` option like so:
38
+
The process starts by gathering all the text used throughout the application. To do this, you need to keep the `Gather from Packages` and `Gather from Text Files` options enabled [0.1.] and tell the engine where to look for translation content. In case of packages, we used path wildcards to search everything inside the `Content` folder [0.2.], which holds all the files for the application. In case of Text Files, we applied the wildcard that searches for `.cpp` and `.h` files within the whole project (that includes `Source` directory containing C++ code) [0.3.].
39
+
(feel free, of course, to change/add any paths to your specific needs)
Next, you can add language(s) you want to support [1.]. Make sure that a 'native' language is English [2.]. Once that is done, click the `Gather Text` button [3.] to collect all the text for translation.
38
42
39
-
# Localization functionality
43
+
The next step is to actually translate the text we need. For this we open the `Translation editor` [4.] through the `Actions` segment of the cultures (First small icon, starting from left, below `Actions`).
We use dispatchers for the buttons since they are reusables, then we simply set the preffered culture using the `Set Current Culture` node where we specify the culture. (The `Hide All Dots` and `Set Dot Visible` nodes are for UI purposes only).
47
+
Later, in the translation editor we simply translate the words we need manually. Watch out on `Untranslated`/`Completed` tabs [1.] and do not forget about the `Save` button [2.] to save your changes.
44
48
45
-
To make sure we are getting the correct specification of the culture we can check it by hovering over the cultures in the `Localization Dashboard`:
It is possible to use third party services to translate, using `Portable Object` files. As these third party services are usually paid we refrained from using them, considering the scale of the application.
49
54
55
+
## Changing the language in the application
50
56
57
+
The change of the language in the application can be done through interaction with `WB_SettingsPage` (or simply Settings page).
58
+
59
+
Also, all behaviour and code logic inside `WB_SettingsPage` is implemented using Blueprints. In order to see the Blueprint functions, you need to go to switch from `Design` to `Graph` mode in the Widget Blueprint editor.
60
+
61
+
For switching between languages (English and Dutch), we use dispatchers for the buttons since they are reusable, then we set the preferred culture using the `Set Current Culture` node where we specify the culture.
62
+
63
+
(The `Set Dot Visible` node is for UI purposes and casting to `CPP_GameInstance` and the `SaveCultureSetting` function are for saving the application state feature - it is a different topic).
0 commit comments