# Localization Manager

{% hint style="info" %}
Currently Localization Manager supports only localization files in \*.txt format with key=value pairs inside. But in future we're planning to extend this system functionality, so it will support more localization data formats.
{% endhint %}

To use this system, inject ILocalizationManager interface into your class, as shown below:

```csharp
[Inject] private ILocalizationManager localizationManager;
```

### Available methods

```csharp
void SwitchLanguage(SystemLanguage lang)
```

*This method switches current language to the needed one, passed via **lang** parameter.*

*Example:*

```csharp
localizationManager.SwitchLanguage(SystemLanguage.French);
```

***

```csharp
string GetLocalizedString(string id)
```

*This method returns localized string with **id** localization key. If this key is not presented in localization table, it just returns **id**.*

*Example:*

```csharp
resultLabel.text = localizationManager.GetLocalizedString("Success");
```

***

```csharp
string GetLocalizedString<T>(string id, params T[] args)
```

*This method returns localized string with **id** localization key and custom parameters **args**. If this key is not presented in localization table, it just returns **id**. Parameters can have any types, convertable to string. In localization table parameters are presented as {0}, {1}, ... {N} terms.*

*Example:*

{% code title="Localization key and value" %}

```
Attempt=Attempt {0}
```

{% endcode %}

{% code title="Getting localized string" %}

```csharp
attemptLabel.text = localizationManager.GetLocalizedString("Attempt", attemptNumber);
```

{% endcode %}

So, in case if attemptNumber = 3, this method returns:

```
Attempt 3
```

***

```csharp
string GetLocalizedString<T>(string id, Color paramsColor, params T[] args)
```

*This method returns localized string with **id** localization key and custom parameters **args**. If this key is not presented in localization table, it just returns **id**. Parameters can have any types, convertable to string. In localization table parameters are presented as {0}, {1}, ... {N} terms. Parameters in localized string will be shown with text color equal to **paramsColor**.*

*Example:*

```csharp
attemptLabel.text = localizationManager.GetLocalizedString("Attempt", Color.green, attemptNumber);
```

***

```csharp
void ResolveTexts()
```

*This method finds and translates all **Text**, **TMP\_Text** and **TextMesh** components in project. It processes them only in case if that GameObjects also have* [***LangText***](https://heroicsolo.gitbook.io/heroic-engine/basics/publish-your-docs/core-systems/localization-manager/langtext-component) *component with assigned localization key. This method is automatically called right after calling **SwitchLanguage** method*.

***

```csharp
List<SystemLanguage> GetAvailableLanguages()
```

*This method returns list of available languages in project (languages which have their translation files in **Assets/Resources/Localization** folder).*

***

```csharp
SystemLanguage GetCurrentLanguage()
```

*This method returns current language in game.*
