Skip to content

About

A .csv-based localization for Unity project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Simple Localization for Unity

A lightweight, easy-to-use localization system for Unity supporting TextMeshPro UI text, dynamic string formatting, ScriptableObject language configuration, automatic keyword coloring, localized audio clips, and one-click Google Sheets CSV synchronization.


Features

  • Auto Setup Installer Window — Automatically pops up on first install (or anytime via Tools > Simple Localization > Setup Resources) to create LocalizationData.csv, SupportedLanguages.asset, ColorTexts.asset, and Audio/ folders directly in Assets/Resources/Localization/.
  • CSV-Based Text Localization (UTF-8 with BOM) — Excel-friendly UTF-8 with BOM encoding, supporting multi-language columns, commas and quotes inside sentences, and dynamic string.Format arguments ({0}, {1}).
  • Configurable Supported Languages — Manage active languages in the Unity Inspector via the SupportedLanguages ScriptableObject (Create > Localization > Supported Languages).
  • Auto Color Keywords (ColorTexts) — Automatically highlight specific words or phrases across all localized strings with custom colors via a ColorTexts ScriptableObject.
  • Audio Localization — Automatically swaps AudioClip assets on an AudioSource per language based on the localization key.
  • Google Sheet Sync Tool — Built-in Editor window (Tools > Simple Localization > Google Sheet Sync) that downloads your Google Sheet directly into LocalizationData.csv (encoded as UTF-8 with BOM).

Installation

1. Install via Git URL (Unity Package Manager)

  1. Open Window > Package Manager in Unity.
  2. Click the + button in the top-left corner and select Add package from git URL....
  3. Enter the package Git URL:
    https://github.com/project-SIMPLE/com.simple.localization.git
    

2. Initialize Project Resources (Setup Window)

As soon as the package finishes installing, the Simple Localization Setup window automatically pops up if Assets/Resources/Localization has not been set up yet.

  • You can also open this window at any time from Tools > Simple Localization > Setup Resources.
  • Check the items you want to create in your project (LocalizationData.csv, SupportedLanguages.asset, ColorTexts.asset, and Audio/ folders) and click Install Selected Resources.

Folder Structure (Assets/Resources/Localization)

At runtime, LocalizationManager and LocalizedKey load data from Assets/Resources/Localization/:

Assets/
└── Resources/
    └── Localization/
        ├── LocalizationData.csv          # Main translation table - UTF-8 with BOM (Required)
        ├── SupportedLanguages.asset      # Active languages list (Required)
        ├── ColorTexts.asset              # Auto-colored keywords (Optional)
        └── Audio/                        # Localized voiceovers/audio (Optional)
            ├── English/
            │   └── <localizationKey>.wav
            ├── Vietnamese/
            │   └── <localizationKey>.wav
            └── French/
                └── <localizationKey>.wav

Basic Setup: Localizing Text

1. Configure Supported Languages (SupportedLanguages.asset)

LocalizationManager reads Assets/Resources/Localization/SupportedLanguages.asset to determine which language columns in the CSV should be loaded.

  1. Use Tools > Simple Localization > Setup Resources to generate SupportedLanguages.asset automatically (or right-click Assets/Resources/Localization and select Create > Localization > Supported Languages).
  2. In the Inspector, add the exact names of the languages you want to use (e.g., English, Vietnamese, French).

    Important: Each language name must match its corresponding column header in LocalizationData.csv.


2. Create or Edit LocalizationData.csv

Edit Assets/Resources/Localization/LocalizationData.csv (saved as UTF-8 with BOM so Vietnamese/French accents display properly in Microsoft Excel):

  • Column 0 must be the Localization Key.
  • Subsequent columns represent languages (headers must match the entries in SupportedLanguages.asset). Any extra helper columns (such as Notes or Scene) not listed in SupportedLanguages.asset are safely ignored.
  • Commas , and quotation marks " inside sentences are automatically handled by the CSV parser.
  • Use {0}, {1}, etc. for dynamic runtime values.

Example LocalizationData.csv:

Localization Key,English,Vietnamese,French,Notes
mainMenu.start,Start,Bắt đầu,Commencer,Main menu start button
mainMenu.options,Options,Tùy chọn,Options,Main menu options button
mainMenu.end,Exit,Thoát,Quitter,Main menu exit button
sample.greeting,"Hello, welcome!","Xin chào, chào mừng!","Bonjour, bienvenue !",Contains comma
sample.score,Score: {0}/{1},Điểm: {0}/{1},Score : {0}/{1},Dynamic arguments

3. Add LocalizationManager to Your First Scene

  1. Create an empty GameObject named LocalizationManager in your initial/bootstrap scene.
  2. Attach the LocalizationManager component to it.
  3. In the Inspector, set Current Language to your default startup language (e.g., English or Vietnamese).
    • LocalizationManager uses DontDestroyOnLoad automatically and persists across scenes as LocalizationManager.Instance.

4. Localize UI Text with LocalizedKey

  1. Select any GameObject in your scene that has a TextMeshPro - Text (UI) (TextMeshProUGUI) component.
  2. Add the LocalizedKey component.
  3. Set Localization Key in the Inspector (e.g., mainMenu.start).
    • If Text Component is left empty, LocalizedKey automatically grabs the TextMeshProUGUI component on the same GameObject on Start().

5. Switching Languages & Using Dynamic Text in Code

Switch the Active Language

LocalizationManager.Instance.SetLanguage("English");

All active LocalizedKey components in the scene automatically subscribe to LocalizationManager.OnLanguageChanged and refresh immediately.

Pass Dynamic Format Arguments ({0}, {1}, ...)

If your CSV value is "Score: {0}/{1}":

LocalizedKey scoreText = GetComponent<LocalizedKey>();
scoreText.SetFormatArguments(currentScore, maxScore);

Fetch Localized Text Directly in C#

string text = LocalizationManager.Instance.GetLocalizedValue("sample.greeting");
string currentLang = LocalizationManager.Instance.GetLanguage();

Listen to Language Changes in Custom Scripts

private void OnEnable()
{
    LocalizationManager.OnLanguageChanged += OnLanguageChanged;
}

private void OnDisable()
{
    LocalizationManager.OnLanguageChanged -= OnLanguageChanged;
}

private void OnLanguageChanged()
{
    // Refresh custom UI or state
}

Supplementary Features

1. Audio Localization

LocalizedKey can automatically load and assign localized AudioClip files when the language changes.

  1. Place your audio files under Assets/Resources/Localization/Audio/<LanguageName>/<LocalizationKey> (e.g., .wav, .mp3, .ogg).
    • Example for key Key.Narrator.Dialogue.01:
      • Assets/Resources/Localization/Audio/English/Key.Narrator.Dialogue.01.wav
      • Assets/Resources/Localization/Audio/Vietnamese/Key.Narrator.Dialogue.01.wav
      • Assets/Resources/Localization/Audio/French/Key.Narrator.Dialogue.01.wav
  2. On the GameObject with LocalizedKey, add or reference an AudioSource component in the Audio Source field of LocalizedKey.
  3. Whenever the scene starts or LocalizationManager.Instance.SetLanguage(...) is called, LocalizedKey automatically loads the matching AudioClip for the active language and assigns it to audioSource.clip.

2. Auto Color Keywords (ColorTexts)

You can automatically highlight specific words or terms across all localized text without manually writing <color=#...> tags in every cell of your CSV.

  1. Open Assets/Resources/Localization/ColorTexts.asset (or create it via Tools > Simple Localization > Setup Resources / Create > Localization > Color Texts).
  2. In the Inspector, add entries to the Color Texts list:
    • Text: The word or phrase to highlight (e.g., RIVIERE, PFAS, Warning).
    • Color: The color to apply.
  3. Ensure Rich Text is enabled on your TextMeshProUGUI components (enabled by default).
  4. When LocalizationManager loads the CSV data, every occurrence of each configured word is automatically wrapped in <color=#RRGGBB>...</color> (case-insensitive matching while preserving the original uppercase/lowercase text).

3. Google Sheet Sync

Instead of manually exporting and copying CSV files, you can synchronize LocalizationData.csv directly from Google Sheets inside the Unity Editor.

Step 1: Prepare Your Google Sheet

  1. Create your localization table in Google Sheets (Row 1 = headers with Localization Key and your language names).
  2. Share the Google Sheet so Unity can download it:
    • Click Share (top-right in Google Sheets) → Under General access, select Anyone with the link (Viewer), OR
    • Go to File > Share > Publish to web and publish the sheet as Comma-separated values (.csv).

Step 2: Sync in Unity Editor

  1. In Unity, open Tools > Simple Localization > Google Sheet Sync.
  2. Configure the fields:
    • Google Sheet CSV URL: Paste your Google Sheet link. You can paste either:
      • The standard browser URL (https://docs.google.com/spreadsheets/d/<ID>/edit#gid=0) — the tool automatically converts /edit or /view links into direct CSV export URLs (.../export?format=csv&gid=...).
      • Or a direct CSV export / published link.
    • Save Path: Path where the downloaded CSV will be saved (default: Assets/Resources/Localization/LocalizationData.csv).
  3. Click Synchronize Now.
  4. Unity will download the CSV, validate that it is not an HTML login page, save LocalizationData.csv as UTF-8 with BOM (so it opens cleanly in Excel), and refresh the AssetDatabase.
    • Your URL and Save Path are automatically saved in EditorPrefs between sessions.

About

A .csv-based localization for Unity project

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages