Localization is a tricky issue in Unreal. All the tools are there, it's just a case of finding out how to use them. In this tutorial we will load localized strings from a central .csv file (also known as a StringTable), and use them in both the editor and C++.
Here is the general workflow we will follow
- Create a CSV (comma-separated values) file.
- Modify Game Module class in C++.
- Use our localized strings in C++ or the editor.
For the purposes of this example, our project is called
1. Create a CSV File
Save it in your project's Content directory, anywhere you like. Remember this path,
For the purposes of this example, we will be saving ours as:
A few points about .csv files in Unreal:
- You can surround your strings with quotes, to let you use commas in your strings
- If you use quotes, you can use new-lines in your strings
- If you use quotes, you can use double-quotes to escape. e.g. "She said ""See ya!"" and left"
2. Modify our Game Module Class
In order for our String Table to be available from the editor, in drop-down menus, we need to load it when our Game Module gets loaded.
3. Using Stringtable Values
Now we can use the strings in our .csv file when editing Blueprints from C++.
If we called our StringTable
UIStrings like in the example above, we can load one of the strings with the following:
We can also edit and add new entries the CSV, and the values will be available in Unreal as soon as we save the file.
In the Editor
FText variables will be displayed with the dropdown shown in the screenshot.
Note: By default Unreal will not include your CSV file(s) as part of the packaging process, even if they are inside the content folder. Make sure to add your CSVs directory to Additional Non-Asset Directories to Package in your project's Packaging settings.