# Tr

> This function referes a po file like ja.po as an asset. Asmdef and [assembly: UnityEditor.Localization] is needed.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.7/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## Tr(string)

This function referes a po file like ja.po as an asset. Asmdef and \[assembly: UnityEditor.Localization] is needed.

```csharp
public static string Tr(string str)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Original text, basically English.

### Returns

| Type                                                           | Description     |
| -------------------------------------------------------------- | --------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | Localized text. |

### Remarks

Unity takes the group from the [LocalizationAttribute](/engine/6000.7/script-reference/unityeditor/localizationattribute.md) 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.

### Examples

```csharp
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"));
    }
}
```

## Tr(string\[])

Translates an array of strings, using the localization group of the assembly that calls this method.

```csharp
public static string[] Tr(string[] str_list)
```

### Parameters

**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): Original texts, basically English.

### Returns

| Type                                                               | Description                                                                                   |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------- |
| [string\[\]](https://learn.microsoft.com/dotnet/api/system.string) | Localized texts, in the same order as `str_list`. Strings with no translation stay unchanged. |

### Remarks

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.

## Tr(string, string)

Translates a string in the localization group you name.

```csharp
public static string Tr(string str, string groupName)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Original text, basically English.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Localization group to look the string up in.

### Returns

| Type                                                           | Description                                                 |
| -------------------------------------------------------------- | ----------------------------------------------------------- |
| [string](https://learn.microsoft.com/dotnet/api/system.string) | Localized text, or `str` itself when no translation exists. |

### Remarks

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](/engine/6000.7/script-reference/unityeditor/localizationattribute.md) 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 rather than a package group.

## Tr(string\[], string)

Translates an array of strings in the localization group you name.

```csharp
public static string[] Tr(string[] str_list, string groupName)
```

### Parameters

**** (\[string\[]]\(https\://learn.microsoft.com/dotnet/api/system.string)): Original texts, basically English.**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): Localization group to look the strings up in.

### Returns

| Type                                                               | Description                                                                                   |
| ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------- |
| [string\[\]](https://learn.microsoft.com/dotnet/api/system.string) | Localized texts, in the same order as `str_list`. Strings with no translation stay unchanged. |

### Remarks

Every string in the array uses the group you name, so this behaves the same on every scripting backend. A null or empty group name reads the Editor's own translations rather than a package group.
