Register your tool's translation files
To use translations in your editor extension, register the folder that holds your translation files as a “source”. Prepare one source per tool.
Prepare translation files
Section titled “Prepare translation files”-
Create one folder for translation files inside your tool’s folder (for example,
Editor/Localization/). -
Put one JSON file per language directly in that folder. Name each file with a
language-REGIONcode, such asen-US.jsonorja-JP.json.Editor/Localization/├── en-US.json└── ja-JP.json -
In each file, write keys and translated strings as a JSON object.
{"window": {"title": "Sample Tool","apply": "Apply"}} -
After Unity imports the folder, open the folder’s
.metafile in a text editor and copy the value ofguid:.
JSON format
Section titled “JSON format”- The root must be an object, and values can only be strings, objects, or arrays. Numbers, booleans, and
nullcause a load error. - Nested keys are joined with
.into a single key. The example above defines two keys:window.titleandwindow.apply. - Refer to array elements by index, such as
key.0andkey.1.
Register the source
Section titled “Register the source”The entry point is EditorLocalization.Service (IEditorLocalizationService) in the com.amari_noa.unity_editor_localization_core.editor namespace. Register your source in the static constructor of a class marked with [InitializeOnLoad].
using com.amari_noa.unity_editor_localization_core.editor;using UnityEditor;
[InitializeOnLoad]internal static class SampleToolLocalization{ public const string SourceId = "com.example.sample-tool";
static SampleToolLocalization() { EditorLocalization.Service.RegisterSource(new EditorLocalizationSourceDefinition { SourceId = SourceId, DisplayName = "Sample Tool", LocalizationFolderGuid = "GUID from the translation folder's .meta file", DefaultLanguageCode = "en-US", BaseLanguageCode = "en-US" }); }}The fields of EditorLocalizationSourceDefinition are as follows.
| Field | Description |
|---|---|
SourceId |
A unique string that identifies the source. Required. |
DisplayName |
The display name. Defaults to SourceId. |
LocalizationFolderGuid |
The GUID of the folder that holds the translation files. |
DefaultLanguageCode |
The language to fall back to when a key is missing in the current language. Defaults to en-US if empty or invalid. |
BaseLanguageCode |
The base language for key validation. Defaults to en-US if empty or invalid. |
- Because the folder is specified by GUID rather than path, the reference does not break when the package moves.
- Registrations are cleared on every domain reload, so register with
[InitializeOnLoad]each time. RegisterSourcereturns aboolthat tells whether registration succeeded. Registering the sameSourceIdtwice is rejected and returnsfalse.
After you edit translation files
Section titled “After you edit translation files”Loaded translations are cached, so edits to the JSON files do not show up right away. Call Reload(sourceId) to reload one source, or ReloadAll() to reload every source. A domain reload also reloads them.
Copyright (c) 2026 天鈴のあ
