• Hello
Search Results for

    Show / Hide Table of Contents

    How To Start

    This guide walks you through installing LocaleForge, dropping in your translation files, and wiring the language dropdown into your own editor window. By the end you will have a small editor tool that flips its UI between languages with one click and remembers the choice across editor restarts.

    Step 1 - Get & Install LocaleForge

    Grab LocaleForge from the Unity Asset Store and import it into your project. After import you will find the package at Assets/GUPS/LocaleForge.

    You find the following directories and files in the root directory of LocaleForge:

    • Editor: All editor scripts plus the asmdef. The unit tests live under Editor/Tests/.
    • Demo: The optional Scene Title Translator Demo window, useful as a worked example.
    • Resources/Flags/PNG/64: Country flag PNGs that ship with the package.
    • Resources/Localizations: The folder LocaleForge looks at by default for <iso>.json and <iso>.csv translation files.
    • README.md: A local copy of the package readme.

    LocaleForge is editor-only. The asmdef is editor-scoped, so nothing in the package ships into player builds.

    Step 2 - Add your translation files

    Drop your translation files into Resources/Localizations/, one file per language, named after the ISO 639-1 code (en.json, de.json, fr.csv, ...). LocaleForge reads two formats and you can mix them per language.

    JSON is nested. Keys flatten to dot-notation, so menu.title resolves to the title field inside the menu object:

    {
      "menu": { "title": "Main Menu", "play": "Play" }
    }
    

    CSV is two columns separated by ;. The same content as a CSV file looks like this:

    menu.title;Main Menu
    menu.play;Play
    

    Both formats end up as the same flat dictionary at runtime, so the choice is a tooling preference. Pick JSON when you hand-edit nested screens, pick CSV when you import translator-spreadsheet output.

    Step 3 - Opt your languages in

    Edit Configuration.SupportedLanguages in Editor/Source/Configuration.cs to list every language your tool offers in the dropdown:

    public static readonly ELanguage[] SupportedLanguages =
    {
        ELanguage.English,
        ELanguage.German,
        ELanguage.French,
    };
    

    Configuration.Fallback (English by default) should always also appear in this list so LocaleForge has a guaranteed language to fall back to when nothing else matches.

    Step 4 - Use it in your editor UI

    Drop the dropdown helper into any EditorWindow, Editor, or EditorWindow-style OnGUI and translate every label through Localizations.t(...):

    public sealed class MyToolWindow : EditorWindow
    {
        [MenuItem("Window/My Tool")]
        public static void Open() => GetWindow<MyToolWindow>();
    
        private void OnGUI()
        {
            LocaleForgeEditorGUILayout.LanguageDropdown(
                new GUIContent("Language"),
                GUILayout.MaxWidth(260f));
    
            GUILayout.Label(Localizations.t("menu.title"));
        }
    }
    

    What just happened: when the user picks a language in the dropdown, the popup's internal EnsureLoaded calls Localizations.Load(language) for you. As long as your <iso>.json (or <iso>.csv) lives under Configuration.LocalizationRoot you do not have to call Localizations.Load(...) yourself. Tooling that needs to load files from outside that folder can still call any of the Localizations.Load(...) overloads explicitly:

    Localizations.Load(ELanguage.German, "Assets/MyGame/Loc/de.csv");
    Localizations.Load(ELanguage.French, path, LocalizationFormat.Json);
    Localizations.LoadFromString(ELanguage.Spanish, csvText, LocalizationFormat.Csv);
    

    Localizations.t("menu.title") returns the translated value when the key exists and the raw key ("menu.title") when it does not. That makes missing translations easy to spot in the UI without crashing your tool.

    Step 5 - Run the demo (optional)

    Open Window > GuardingPearSoftware > LocaleForge > Scene Title Translator Demo to see the dropdown, the lookup helpers, and the persistence layer wired up against three real locales. The demo source under Demo/Editor/ is small on purpose; copy from it whenever you want a working reference for your own tool.

    In This Article
    Back to top GuardingPearSoftware documentation