| Parameter | Description |
|---|---|
| str | Original text, basically English. |
string Localized text.
This function referes a po file like ja.po as an asset. Asmdef and [assembly: UnityEditor.Localization] is needed.
Unity takes the group from the LocalizationAttribute on the calling assembly. If that assembly has no attribute, Unity uses the Editor's own translations.
Note: On the CoreCLR scripting backend, Unity can't reliably identify the calling assembly, because the JIT compiler can inline the caller and remove its stack frame. Use the overload that takes a group name and pass one explicitly to avoid this. For text belonging to the Editor itself rather than to an assembly carrying its own translations, pass a null or empty group name.
using UnityEngine; using UnityEditor;
// This is not an editor script. public class MyScript : MonoBehaviour {}
[CustomEditor(typeof(MyScript))] public class MyScriptInspector : Editor { MyScript m_Target = null; void OnEnable() { m_Target = target as MyScript; }
public override void OnInspectorGUI() { base.OnInspectorGUI(); EditorGUILayout.LabelField(L10n.Tr("Cancel")); } }
| Parameter | Description |
|---|---|
| str_list | Original texts, basically English. |
string[]
Localized texts, in the same order as str_list. Strings with no translation stay unchanged.
Translates an array of strings, using the localization group of the assembly that calls this method.
Every string in the array uses the same group, which Unity identifies once per call.
Note: This has the same CoreCLR limitation as the single string overload. Use the overload that takes a group name.
| Parameter | Description |
|---|---|
| str | Original text, basically English. |
| groupName | Localization group to look the string up in. |
string
Localized text, or str itself when no translation exists.
Translates a string in the localization group you name.
This overload names the group directly instead of identifying the calling assembly, so it behaves the same on every scripting backend. Use it wherever the group matters.
The group name is the one you give to LocalizationAttribute on the assembly that holds the translations, or that assembly's name when the attribute names no group. A null or empty group name reads the Editor's own translations.