JSON tables (legacy workflow)
A simple workflow for text only, without Unity Localization tables. It was inspired by ikuko/ULocalization.
Smart Strings and localized sprites, textures, audio and GameObjects are described under Unity String Tables and Localized assets. Use that workflow for them.
Setup without code
- Open Tools > LCG Localization > Legacy JSON Table and click Create Localization Manager.
- Click Save Table and save the JSON under
Assets. - Select text objects, or their parent, then click Bind Selected Text.
- Enter the translations. Add any language code, such as
en,th,jaorzh-hant. - Click Save Table, then save the scene.
Bind Selected Text supports TextMeshPro and legacy UI Text, including inactive children. The current text becomes the default translation, and keys are created for you. Text that belongs to another manager isn't changed. The component Inspector has a key picker.
Table format
{
"en": { "hello": "Hello" },
"th": { "hello": "สวัสดี" }
}
The table is read once for each manager at runtime. Restart Play mode to see edits to the file.
Language buttons
Add LCG Language Button, assign the manager and enter a language code. Leave the code empty to cycle through languages.
| Button type | Setup |
|---|---|
| Unity UI Button | Click Wire UI Button in the Inspector |
| World object with a collider | Works through Interact() |
Missing text
Default Language supplies missing translations. If it has none either, the text component shows its Fallback Text. Get(key) returns the key itself.
For numbers, you can format the text yourself:
// "Score: {0}" in the table
label.text = string.Format(localization.Get("score"), score);
Fonts
TextMeshPro fonts need glyphs for every language you show. Add suitable fonts or fallback fonts. Localization changes the text, not the font.
Example
Open LocalizationExample.unity from the sample and enter Play mode. The English, Thai and Japanese buttons are already connected. The LocalizationExample object has a RunChecks event that sets checksPassed.