Build a language switcher
Add language options to your tool’s UI so users can switch the display language. The new language applies to every tool that uses this library.
List the options
Section titled “List the options”GetAvailableLanguages(sourceId) returns the language codes found in the source’s translation folder. CurrentLanguageCode returns the current language.
var service = EditorLocalization.Service;var languages = service.GetAvailableLanguages(SampleToolLocalization.SourceId);var current = service.CurrentLanguageCode;Switch the language
Section titled “Switch the language”Call SetLanguage(sourceId, languageCode) to switch the display language. The sourceId is used to check that a translation file exists for the new language, and the change applies to every source.
var result = EditorLocalization.Service.SetLanguage(SampleToolLocalization.SourceId, "ja-JP");The return value, EditorLocalizationSetLanguageResult, is one of the following.
| Value | Meaning |
|---|---|
SUCCESS |
The language switched to the one you specified. |
NOT_FOUND |
No file exists for that language. A dialog was shown and the language switched to en-US. |
FAILED |
Loading failed and the language did not change. |
NOT_REGISTERED |
The sourceId is not registered. |
Copyright (c) 2026 天鈴のあ
