Skip to content

Commit 880710c

Browse files
committed
Update Localization.md
1 parent 9edbd42 commit 880710c

File tree

6 files changed

+43
-21
lines changed

6 files changed

+43
-21
lines changed

docs/Virtual-Anatomy-(Unreal-Engine)/Localization.md

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,69 @@ weight: 1
44

55
# Localization
66

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.
88

9-
# Localization dashboard configuration
9+
## Adding new text for localization
1010

11-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/localization-dashboard.png)
11+
### Text within Blueprint
1212

13-
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.].
1414

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.
15+
![Localization usage](../images/umg-localization.png)
1616

17-
The next step is to actually translate the text we need. For this we open the `Translation editor` through the `Actions` segment of the cultures.
17+
Enabling this ensures that the text will be included when gathering content for translation.
1818

19-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/translation-actions.png)
19+
### Text within C++ code
2020

21-
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`:
2222

23-
**Note**
23+
```cpp
24+
NSLOCTEXT([Namespace], [Key], [Source String]);
25+
e.g. NSLOCTEXT("SomeNamespace", "SomeKey", "This is the text to be localized");
26+
```
2427
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.
2629
27-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/translation-editor.png)
30+
!!! Warning
2831
29-
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.
3033
31-
`save > gather text > compile text`
34+
## Localization configuration and modification
3235
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.
3437
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)
3640
37-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/umg-localization.png)
41+
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.
3842
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`).
4044
41-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/localization-functionality.png)
45+
![Localization usage](../images/localization-dashboard.png)
4246
43-
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.
4448
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`:
49+
![Localization usage](../images/translation-editor.png)
4650
47-
![Localization usage](https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/images/culture-spec.png)
51+
!!! Note
4852
53+
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.
4954
55+
## Changing the language in the application
5056
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).
64+
65+
![Localization usage](../images/localization-functionality.png)
66+
67+
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:
68+
69+
![Localization usage](../images/culture-spec.png)
70+
71+
(though by default `en` is English, `nl-NL` is Dutch)
5172
148 KB
Loading
827 KB
Loading

docs/images/translation-editor.png

69.7 KB
Loading

docs/images/umg-localization.png

63.6 KB
Loading

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ site_url: https://jrcz-data-science-lab.github.io/VirtualAnatomy-Documentation/
66
docs_dir: docs
77
repo_name: 'Virtual-Anatomy-UE'
88
repo_url: 'https://github.com/jrcz-data-science-lab/Virtual-Anatomy-UE'
9+
use_directory_urls: true
910
markdown_extensions:
1011
- attr_list
1112
- md_in_html

0 commit comments

Comments
 (0)