> For the complete documentation index, see [llms.txt](https://giantgrey.gitbook.io/databrain/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giantgrey.gitbook.io/databrain/add-ons/localization/examples.md).

# Examples

Here are some code examples.

### Get localized string

<div align="left"><figure><img src="/files/E7fUeL39LWZoi8eSUbdE" alt=""><figcaption></figcaption></figure></div>

Get the localized string from the localization object named "TextManual":

<pre class="language-csharp"><code class="lang-csharp"><strong>public class LocalizationExample : MonoBehaviour
</strong><strong>{
</strong><strong>    public LocalizationManager manager;
</strong><strong>    
</strong><strong>    public void LoadText()
</strong><strong>    {
</strong><strong>        var _localizedText = manager.GetLocalizedText("TextManual");
</strong><strong>    }
</strong><strong>}
</strong></code></pre>

### Load text with parameters

The Localization add-on supports tag replacements for text.

<div align="left"><figure><img src="/files/QJV6msF5IbEY7Cqwj3Vz" alt=""><figcaption></figcaption></figure></div>

```csharp
// First, define parameters.
// The tag {NAME} must be assigned in the localized text. This part, will then be replaced.
var _params = new Dictionary<string, object>();
_params.Add("{NAME}", inputField.text);

var _localizedTextWithTag = localizationManager.GetLocalizedText("TextParameter", _params);
```

### Set language

```csharp
public class LocalizationExample : MonoBehaviour
{
    public LocalizationManager manager;
    
    public void SetLanguage()
    {
        manager.SetLanguage("English");
    }
}
```

### Get all languages and current language

```csharp
public class LocalizationExample : MonoBehaviour
{
    public LocalizationManager manager;
    
    public void SetLanguage()
    {
        // get all languages
        List<LocalizationManager.Languages> _allLanguages = manager.languages;
        
        // Get current language
        var _currentLanguage = manager.currentLanguage;
    }
}
```
