Skip to content

RenKOFFF/Simply-Localize-Localization-System-for-Unity

Repository files navigation

Simply Localize

A localization system for Unity, designed to simplify the management of translations and text handling for multiple languages in your project.

Read in other languages: Russian.

Table of Contents

Features

Note

  • Convenient storage: all translations are stored in a single JSON file and editor.
  • Parameterization: supports formatted texts with parameters.
  • Custom editor: allows adding keys both through the settings window and directly via localization components.
  • Runtime language switching: change the active language during gameplay.
  • Image localization: supports localization of images.
  • Automatic key generation: no need to add keys manually in the code.

Note

  • Localization of app title: The package does not provide the ability to localize the app title. It is recommended to use Unity Localized App Title for this.

Example

Localization File

{
  "en": {
    "Version": "Version {0}",
    "WelcomeMessage": "Welcome!",
    "Game/Inventory/Armor/Body": "Body Armor",
    "Game/Inventory/Armor/Head": "Head Armor",
    "Game/Inventory/Armor/Legs": "Leg Armor",
    "UI/MainMenu/Play": "Play",
    "UI/MainMenu/Quit": "Quit",
    "UI/MainMenu/Settings": "Settings"
  },
  "ja": {
    "Version": "バージョン {0}",
    "WelcomeMessage": "ようこそ!",
    "Game/Inventory/Armor/Body": "胴防具",
    "Game/Inventory/Armor/Head": "頭防具",
    "Game/Inventory/Armor/Legs": "脚防具",
    "UI/MainMenu/Play": "プレイ",
    "UI/MainMenu/Quit": "終了",
    "UI/MainMenu/Settings": "メインメニュー"
  },
  "ru": {
    "Version": "Версия {0}",
    "WelcomeMessage": "Добро пожаловать!",
    "Game/Inventory/Armor/Body": "Нагрудник",
    "Game/Inventory/Armor/Head": "Шлем",
    "Game/Inventory/Armor/Legs": "Поножи",
    "UI/MainMenu/Play": "Играть",
    "UI/MainMenu/Quit": "Выйти",
    "UI/MainMenu/Settings": "Настройки"
  }
}

Note

The examples contain a complete example of a localization file and a customized scene.

Editor Usage

Unity-R6-H9o-Xq-EOh.png Unity-b-M2doz-EGYT.png

Code Usage

Basic Implementation

To set localized text with parameter:

// Setting text by localization key
VersionText.TranslateByKey("Version");
// Setting dynamic parameter
VersionText.SetValue("1.0.1");

/* Результат:
 * en: "Version 1.0.1"
 * ru: "Версия 1.0.1"
 */

Note

  1. Method TranslateByKey is optional if key is set in Unity inspector
  2. Method TranslateByKey can override existing keys

Language Switching

Localization.SetLocalization("ru");

The change applies to all active UI elements using the localization system.

Installation

  1. Download and install the asset via the link: Window > Package Manager > Add package from git URL
https://github.com/RenKOFFF/SimplyLocalize.git
  1. If you want to localize the app title on Android or IOS, install the third-party package Unity Localized App Title. You can add the package similar to the SimplyLocalize package or use one of the options from the original repository.
https://github.com/yasirkula/UnityMobileLocalizedAppTitle.git

Usage

After installation, a new menu will appear in Unity: Window -> SimplyLocalize -> Localization Settings.

In this window, you can:

  • Add new languages and fonts for specific languages.
  • Create and edit keys.
  • Set translations for each language.
  • Configure editor behavior:
    • Text-to-key conversion settings: replace spaces with slashes, underscores, or leave unchanged.
    • Enable/disable logging.

Unity-6o-AKl-J7x-Vb.gif

Component setup

Add one of the localization components to UI elements:

LocalizationText

  • Purpose: For static text without dynamic changes
  • Usage:
    1. Add the component to TextMeshPro or regular text
    2. Select the localization key from the list

FormattableLocalizationText

  • Purpose: For dynamic text with parameters (e.g. "Health: {0}/{1}")
  • Features:
    • Support for parameters in the string.Format style
    • Default values
  • Usage:
    1. Add the component to the text object
    2. Enter the key with placeholders (e.g. "STATS_HEALTH_{0}_{1}")
    3. Set the parameters via code: .SetValue(100, 200)
    4. Set default value in editor (optional)

Important

  • translation text must contain a fragment with the {n} parameter (e.g. "STATS_HEALTH_{0}_{1}")

LocalizationImage

  • Purpose: For localized images
  • Usage:
    1. Add component to Image
    2. Add sprite key from the list of keys in the editor window from the "Sprites" tab

Changing Language and Setting a Default Language

Call the method to set the language:

Localization.SetLocalization("ru"); // Set Russian language.

Tip

  • You can set the default language in the localization settings window and change it during gameplay if needed.
  • Setting a default language is optional. The key is to set the language before any localization scripts execute.

Alternative Method for Adding Keys

Keys can also be added directly through text components.

Unity-srfu-Fb-Dd-Z7.png

About

A simple localization system for Unity

Topics

Resources

License

Stars

Watchers

Forks

Languages