LocalizationX Lite Document
Download and import the Example
Navigate to the main menu and select: Window > LocalizationX Lite
1. Settings
- Scripts Output Folder: Stores exported C# scripts, including Localization Components, and Localization API.
- Localization Output: Stores Localization Data, which should be inside the Resources folder for loading via Resources, or in the Localizations folder for loading via Addressable Asset System.
- Language Char Sets: Used in Localization with TextMeshPro to compile the character table of a language, mainly applied for Korean, Japanese, and Chinese due to their extensive character systems.
- Google Client ID: Enter your Google Client ID (retrieved from Credentials in Google Console).
- Google Client Secret: Enter your Google Secret (retrieved from Credentials in Google Console).
2. Export from Excel Spreadsheets
- Select the Excel file you want to process.
- Click the
Export All
button to process.
3. Export from Google Spreadsheets
3.1. Setup Google Client ID and Client Secret
Copy the Client ID and Client Secret, and paste them into the text boxes.
3.2. Access Google Spreadsheets
Enter the Google Sheet Id. The Google Sheet Id look like this.
https://docs.google.com/spreadsheets/d/[GOOGLE_SHEET_ID]/edit?......
4. Rules in Spreadsheet
Naming Conventions for Localization Sheets:
- The sheet name must start with
Localization
. - Each sheet has two key columns: the main key
idString
and an additional keyrelativeId
. - The following columns contain localized content.
- The key for each row is a combination of
idString
andrelativeId
. relativeId
is an optional column that helps organize localization data.
| idString | relativeId | english | spanish | japan | .... |
| -------- | ---------- | ------- | ------- | ----- | ---- |
For more details, please refer to the example Excel file.
5. How to integration
Download and import the Example
First, open the Excel file at /Assets/LocalizationXLite/Example/Example.xlsx
. This file has example data to help you understand how to create Localization sheets
For the example using Google Sheets, you can view the file here.
5.1. Create folders for exporting files
Create 2 directories to store the files that will be exported:
- A folder to store the C# scripts (Localization Component and Localization API).
-
A folder to store the Localization data.
- There are two ways to set up the folder for Localization data, depending on how you want to load Localizations:
- The easiest method is to load from the Resources folder. Create a folder inside the Resources folder to store Localization data. You can name this folder anything you like.
- Alternatively, use the Addressable Asset System. In this case, create a “Localizations” folder outside the Resources folder and set it as an Addressable Asset. It’s recommended to name this folder “Localizations”.
- There are two ways to set up the folder for Localization data, depending on how you want to load Localizations:
- Set up the paths for the “Scripts Output Folder”, and “Localization Output Folder” using the folders you just created.
Example for 2 folders:
Assets\LocalizationXLiteExample\Scripts\Generated
: for C# scriptsAssets\LocalizationXLiteExample\Resources\Localizations
: for Localization data
5.2. Scripting
- Initialization
Localization.Init();
- Change the language.
// Set the language japanese
Localization.CurrentLanguage = "jp";
- Register an event handler for the language change event.
// Register an action when language changed
Localization.OnLanguageChanged += OnLanguageChanged;
-
You can retrieve localized content using three different methods.
-
Retrieve localized content using a Key. Note that the text will not automatically refresh when the language changes using this method.
// Retrieve localized text using an integer key m_simpleText1.text = Localization.Get(Localization.NOT_ENOUGH_GOLD).ToString(); // Retrieve localized text using an integer key with an argument m_simpleText2.text = Localization.Get(Localization.LEVEL_UP_X, 10).ToString(); // Retrieve localized text using a string key with an argument m_simpleText3.text = Localization.Get("LEVEL_UP_X", 25).ToString();
-
Link a GameObject containing a Text or TextMeshProUGUI component with a key so that the text automatically updates when the language changes.
// Register dynamic localized text using an integer key Localization.RegisterDynamicText(m_dynamicText1.gameObject, Localization.DOUBLE_TAP); // Register dynamic localized text using an integer key with an argument Localization.RegisterDynamicText(m_dynamicText2.gameObject, Localization.REQ_LVL_X, "3"); // Register dynamic localized text using a string key with an argument Localization.RegisterDynamicText(m_dynamicText3.gameObject, "REQ_LVL_X", "30");
// Unregister the gameObject Localization.UnregisterDynamicText(m_dynamicText1.gameObject); Localization.UnregisterDynamicText(m_dynamicText2.gameObject); Localization.UnregisterDynamicText(m_dynamicText3.gameObject);
-
Using Localization Component.
-
5.3. Creating TextMeshPro Fonts for Extensive Languages
To create TextMeshPro fonts for Japanese, Korean, and Chinese, follow these steps using the respective character set files characters_set_jp, characters_set_ko, and characters_set_cn, which include all characters from the localization sheets:
Fonts to use in this example:
- Japanese: NotoSerif-Bold
- Korean: NotoSerifJP-Bold
- Chinese: NotoSerifTC-Bold
Creating TextMeshPro Fonts:
- For each language font, create a TextMeshPro font asset.
- Open the Font Asset Creator window in Unity.
- Under the Character Set section, select Character From File.
- Choose the appropriate character set file (e.g., characters_set_jp) in the Character File section.
5.4. Loading Localization Using the Addressable Assets System
To utilize this feature, follow these steps:
- Install the Addressable Assets System.
- Add
ADDRESSABLES
to the directives list in the Build Settings. - Move the Localizations folder out of the Resources folder. Additionally, relocate the Output folder in the Settings.
- Set the Localizations folder as an Addressable Asset.