Simple CSV localization system for Unreal Engine 4
We wanted to support fan localization for Industries of
Titan and found that
Unreal’s built-in localization system was not exactly what we wanted. So we
made our own!
It differs from Unreal’s localization system in a few ways:
Feature | Unreal Localization | BYG Localization |
---|---|---|
CSV stringtable support | ✔️ | ✔️ |
Add new keys in-editor | ✔️ | ❌ |
Reload text on CSV modification | ✔️ | ✔️ |
Support for fan translations | ❌ | ✔️ |
Show missing loc keys in-engine | ❌ | ✔️ |
Show fallback language text when keys are missing | ❌ | ✔️ |
Blueprint code support | ✔️ | ✔️ |
Multiple localizations for same language | ❓ | ✔️ |
For this example, we will be using English as the Primary Language, but
the system works with using any language as the Primary language.
We are using English as the primary language for our game so we will create
loc_en.csv
inside /Content/Localization/
, the default localization root
directory for localization files.
Key,SourceString,Comment,English,Status
Hello_World,"Hello world, how are you?",General greeting.,,
Goodbye_World,"See you later!",Shown when quitting the game.,,,
Open Project Settings > Plugins > BYG Localization
and set the
following:
Open Window > Developer Tools > BYG Localization Stats
, and hit
Refresh All. Your csv file should be listed there.
After adding the keys to the Stringtable CSV file, choose the entries for all
FText
properties by:
In Blueprint graphs, use GetGameText
in BYGLocalizationStatics
.
FText ButtonLabelText = UBYGLocalizationStatics::GetGameText( "Hello_World" );
FString PathToCSV;
UBYGLocalizationStatics::SetActiveLocalization( PathToCSV );
There is an stats window available in the editor for seeing which localization
files have been detected by the system, how many entries they have, the status
of those entries etc.
Access it through Window > Developer Tools > BYG Localization Stats
.
All of the project settings can be modified through Project Settings > Plugins > BYG Localization
in the editor, or through
Config/DefaultBYGLocalization.ini
Settings include:
/Localization/
).csv
and .txt
)loc_
prefix, no suffix)loc_en.csv
and you want toloc_fr.csv
-UpdateLoc
flag (create a desktop shortcut).loc_fr.csv
file is now populated with all of the primary languageAfter creating loc_fr.csv
and running the game, your CSV file will look like
this:
Key | SourceString | Comment | Primary | Status |
---|---|---|---|---|
NewGameButtonLabel |
New Game | On main menu, starts new game | New Game | New Entry |
ExitGameButtonLabel |
Quit | Exits the program | Quit | New Entry |
After translation, your CSV file should look like this. You can remove the “New Entry” text from the Status column:
Key | SourceString | Comment | Primary | Status |
---|---|---|---|---|
NewGameButtonLabel |
Nouvelle partie | On main menu, starts new game. | New Game | (blank) |
ExitGameButtonLabel |
Quitter | Exits the program. | Quit | (blank) |
As the game is updated, strings will be added, removed or modified.
Key | SourceString | Comment | Primary | Status |
---|---|---|---|---|
NewGameButtonLabel |
Nouvelle partie | On main menu, starts new game. | New Game | (blank) |
ExitGameButtonLabel |
Quitter | On main menu, starts new game. | Quit game | Modified: Was ‘Quit’ |
LoadGameButtonLabel |
Load Game | Shows the load game screen. | Load Game | New Entry |
ProjectName/Plugins/BYGLocalization
.BYGLocalization
to PrivateDependencyModuleNames
inside ProjectName.Build.cs
.loc_en_ui.csv
, loc_en_dialog.csv
.DirectoryPathStructCustomization
The plugin uses Project Settings to search for localization files in the
specified directories. It uses Unreal’s String Table system to register both
the primary language (e.g. English) and the user’s preferred language (e.g.
French).
Fallback works in two ways:
If text is set with UBYGLocalizationStatics::GetText(const FString& KeyName)
and the key is not found, the key is then looked up in the fallback
table.
When running the game, all localization files are parsed and any missing
keys are added to non-primary localization files. This way FText
properties
inside Blueprints will still find keys in the Stringtable for the user’s
selected locale.
A) Changing Namespace or Stringtable ID will break all of the
FText
strings in your Blueprints. You should only set these values once at
the start of the project, and not change them.