One Click Localization

Fast, Value-Based Localization Tool for Unity

Open Source OCL v1.8.2 Unity 2018.4 - 2022+

What is it?

One Click Localization (OCL) is designed around a simple philosophy: you shouldn't have to think about localization while creating your game.

Unlike traditional systems that require assigning abstract string keys (e.g. UI_TITLE_01) before writing any text, OCL is value-based: your original in-editor strings, textures, and audio clips are your keys. When you're ready to localize, OCL automatically parses your scenes and prefabs, collects everything, and allows you to translate directly or with Microsoft Azure Translator in minutes.

Zero Code Setup: With OCL's automatic setup and generic component adapter, you can localize standard Unity UI (Text, Images, RawImages, Audio) without writing a single line of C#.

Demos & Video Tutorials

Quick Start Video Tutorial

Survival Shooter Localized in 2 Minutes

Playable WebGL Demo

Test language switching, audio localization, and dynamic parameter replacement live in your browser:

Launch WebGL Demo

Quick Start

  1. Import Package: Import OCL into your Unity project. All assets reside in Assets/OneClickLocalization.
  2. Configure Build Settings: Ensure all scenes you want to localize are added to File → Build Settings → Scenes In Build.
  3. Open Setup: Open Window → OneClickLocalization → Setup.
  4. One Click Setup: Click Start Automatic Setup. OCL parses your scenes and prefabs, automatically extracts texts, and attaches adapters to UI elements.
  5. Add Languages: Open Window → OneClickLocalization → Localization, add your target languages, and input or auto-translate your strings.
  6. Play & Test: Hit Play in the editor. To test different languages, switch the active language via the editor window or script API.
OCL Package Structure

Unity Compatibility

  • Unity 2020.1+ / 2021 LTS / 2022 LTS — Fully Supported
  • Unity 2019.4 LTS — Tested & Supported
  • Unity 2018.4 LTS — Minimum Supported Version
  • Unity 2017 and older — Deprecated / Unsupported

Editor Tools & Workflow

Data Storage (`OCLSetup.asset`)

OCL persists all configuration and runtime translations in a single ScriptableObject asset: Assets/OneClickLocalization/Resources/OCLSetup.asset.

Source Control Note: Make sure OCLSetup.asset is committed to Git/version control so automated builds, Unity Cloud Build, and teammates have all localizations available.

Automatic Setup Settings

  • Add OCL Component: Automatically attaches OCLComponentAdapter to GameObjects holding supported UI components.
  • Extract Data: Extracts current text, sprite, texture, and audio values into the localization database.
  • Includes / Excludes: Filter which component types to parse. By default: UnityEngine.UI.Text, UnityEngine.UI.Image, UnityEngine.UI.RawImage, UnityEngine.TextMesh, UnityEngine.AudioSource, and NGUI UILabel.
  • Parse Prefabs & ScriptableObjects: Scan project assets recursively with customizable folder filters.

Microsoft Azure Translator

Translate all extracted strings automatically via Azure Cognitive Services. Add your Azure API Key in the Setup window, then click Translate All in the Localization window.

Azure Configuration Tip: When creating your Azure Translator resource, ensure its location is set to Global to prevent 401 authorization errors.

Import & Export (XML and CSV)

You can export your translations to send to professional translators, and re-import them with a single click:

<?xml version="1.0" encoding="UTF-8"?>
<localization>
  <strings>
    <string stringId="Start Game">
      <value lang="French">Commencer la partie</value>
      <value lang="German">Spiel starten</value>
    </string>
  </strings>
</localization>
StringId,French,German
"Start Game","Commencer la partie","Spiel starten"
"Quit","Quitter","Beenden"

Runtime Components

`OCLComponentAdapter`

The adapter handles automatic runtime updates when the language changes. Supported components include:

  • UnityEngine.UI.Text (Strings)
  • UnityEngine.TextMesh (Strings)
  • UnityEngine.UI.Image (Sprites)
  • UnityEngine.UI.RawImage (Textures)
  • UnityEngine.AudioSource (AudioClips)
  • UILabel (NGUI)
Performance: String comparisons have negligible CPU overhead. For Sprites, Textures, and AudioClips, only enable adapter tracking on objects that actually swap assets across languages.

C# Script API Reference

All runtime methods and events are accessed statically via OneClickLocalization.OCL.

Delegates & Events

Event Description
OCL.onLanguageChanged(oldLang, newLang) Triggered whenever the active language changes.
OCL.onActiveChanged(isActive) Triggered when OCL is enabled or disabled.
OCL.onLanguagesChanged() Triggered when languages are added or removed dynamically.
OCL.onLocalizationChanged(id, lang, val) Triggered when a translation value is modified at runtime.

Key Methods

Signature Description
string GetLocalization(string original) Returns translation of string in the current active language.
string GetLocalization(string original, SystemLanguage lang) Returns translation of string for a specific language.
void SetLanguage(SystemLanguage lang) Sets the active language and triggers UI updates.
SystemLanguage GetLanguage() Returns the current active language.
List<SystemLanguage> GetLanguages() Returns list of all supported languages in the project.
void SetLocalization(string id, SystemLanguage lang, string value) Updates or registers a translation value dynamically at runtime.

Use Cases & Code Samples

1. Translating a String in Code

// Simple translation for current language
string translated = OCL.GetLocalization("Game Over");

// Translation for a specific language
string frenchText = OCL.GetLocalization("Game Over", SystemLanguage.French);

2. Dynamic String Parameters

OCL automatically substitutes dynamic parameters defined with ${0}, ${1}:

// Original text: "Player ${0} scored ${1} points!"
string scoreMessage = OCL.GetLocalization("Player ${0} scored ${1} points!", "Alex", 1500);

3. Language Switcher Dropdown (uGUI)

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using OneClickLocalization;

public class LanguageDropdownController : MonoBehaviour
{
    [SerializeField] private Dropdown _dropdown;

    private void Start()
    {
        // Populate dropdown with all supported languages
        List<string> options = new List<string>();
        foreach (SystemLanguage lang in OCL.GetLanguages())
        {
            options.Add(lang.ToString());
        }
        _dropdown.ClearOptions();
        _dropdown.AddOptions(options);

        // Select current language
        _dropdown.value = options.IndexOf(OCL.GetLanguage().ToString());
        _dropdown.onValueChanged.AddListener(OnLanguageSelected);
    }

    private void OnLanguageSelected(int index)
    {
        string selected = _dropdown.options[index].text;
        SystemLanguage newLang = (SystemLanguage)Enum.Parse(typeof(SystemLanguage), selected);
        OCL.SetLanguage(newLang);
    }
}

4. Adding Languages Dynamically

SystemLanguage targetLang = SystemLanguage.Japanese;

if (!OCL.GetLanguages().Contains(targetLang))
{
    OCL.AddLanguage(targetLang);
    OCL.SetLocalization("Welcome", targetLang, "ようこそ");
}

FAQ & Troubleshooting

How does value-based localization compare to key-based systems?
Key-based systems force you to define keys like TXT_MENU_PLAY_BTN before writing text. OCL uses your actual in-scene English/source strings as the keys. You build your game naturally, and OCL handles extraction and mapping with zero overhead.
Why do I get 401 Unauthorized errors with Azure Translator?
Ensure your Azure Translator resource is provisioned with location Global rather than a specific region. Regional resources will return 401 when accessed through global translation endpoints.
How do I integrate OCL with Unity Cloud Build or CI/CD?
All OCL configuration and translations are stored in Assets/OneClickLocalization/Resources/OCLSetup.asset. Ensure this asset file is committed to version control so builds compile with all translation data intact.
Can I localize TextMeshPro?
Yes! OCL includes native TextMeshPro support. During Automatic Setup, ensure TextMeshProUGUI and TextMeshPro are selected in your included component types.

Contact & Community

Have questions or feedback on One Click Localization? Connect with us:

X YouTube Bitbucket Contact