Localization
Last updated
Last updated
Select the Game Localization component in the GAMEMANAGER object.
Click the Enable GLoc Localization button.
If localization is enabled, you can use GString in place of a standard string to automatically localize text.
However, if you choose not to use localization, GString will still function, but it will behave like a regular string field, displaying the text as-is without attempting to fetch a localized value.
You can either open the default Game Localization Table asset or create a new one:
To create a new table, right-click in your desired folder and select:
Create → UHFPS → Localization → Localization Table
To edit the existing table, navigate to:
UHFPS → Scriptables → Game → Localization
, then select GameLocalizationTable
.
To open the Localization Editor, simply select the GameLocalizationTable asset and click Open Localization Editor.
Select an existing language or create a new one by clicking the + button next to the LANGUAGES title.
Before adding localization strings, you must assign a Language Asset. You can either create a new one by clicking the Create Asset button or assign an existing asset if one is already available.
To add a new table sheet section, click the + button next to the TABLE SHEET title. You can name the section however you like, but it's recommended to use CamelCase or snake_case for naming sections and entries to maintain consistency and readability.
To add a new section entry, right-click the section and select Add Entry.
To start defining localization strings, select the desired language, this will open the Language Editor. From there, you can enter translations for each string in the selected language.
Once you’ve finished defining the translations for your languages, simply click Save Asset to store your changes.
If you’ve created a new localization table, make sure to assign it to the Game Localization component by setting it in the Localization Table field.
In order to utilize localized strings, use the GString instead of String in your scripts when creating a string field.
To listen for localization or input changes, you need to subscribe to them. To accomplish this, simply write a subscribe method within the Start function.
Finally, select the desired localization key by clicking the magnifying glass icon located on the right side of the string field. This will open a list of available keys to choose from.
Keep in mind that these methods are dependent on GameLocalization. If localization is disabled, they will no longer function.
First, define all the languages you intend to support. For example, in my case, I added German to the list of languages, without providing translations for the localization strings.
Click Export CSV and save the file to your desired location.
Once you've finished translating all the texts, click Import CSV and select the CSV file containing your translations. This will update the localization table with the newly translated strings.