# Localization

The built-in localization mechanism in Silverlight and WPF allows you to localize any string resource used by the **RadImageEditor** control. Once translated you might use your resources in both Silverlight and WPF projects without changing anything. You can find more information on the localization of the Telerik UI suite [here](https://www.telerik.com/products/wpf/documentation/common-information/common-localization).

There are two ways to implement the localization - using Resource files or a custom localization manager.

## Supported Languages

**RadImageEditor** can be translated in one of the following supported languages using the framework’s localization mechanism:

* English
* German
* Spanish
* French
* Italian
* Dutch
* Turkish

More information on how to achieve this you can find in the [Localization Using Built-in Resources](https://docs.telerik.com/devtools/wpf/common-localization#localization-using-built-in-resources) article.

## Localization Using Resource Files

You can base your localization on the standard resource files provided by the .NET framework. For that purpose you will have to create a separate .Resx file for each one of the languages that your application will support. Imagine that you want to translate your application into English, German and Dutch. In that regard, you will have to add three new resource files to your project:

* RadImageEditorResources.resx - this resource file will store the English (default) resources for the image editor control. Set the **AccessModifier** property to **Public**.

* RadImageEditorResources.de.resx - this resource file will store the German resources for the image editor control. Set the **AccessModifier** property to **No code generation**.

* RadImageEditorResources.nl.resx - this resource file will store the Dutch resources for the image editor control. Set the **AccessModifier** property to **No code generation**.

RadImageEditor is a complex control with numerous strings for localization. In order to be able to distinguish these resources, a unique identifier, called resource key is assigned to each localizable string. A resource file which includes the complete list of the RadImageEditor-related **Resource Keys** along with the strings they are associated with by default can be downloaded at our SDK repository: [Localization](https://github.com/telerik/xaml-sdk/tree/master/ImageEditor/Localization).

The three files should keep the same resource keys, whereas the values must be the translated ones.

> tip It is easiest to copy the default **RadImageEditorResources.resx** file and rename it. Afterwards, go through all string and change only the values for the strings that will be used in your application.

The last step is to instantiate the **LocalizationManager** class and set its **ResourceManager** to the resources that have been just created.

**Create LocalizationManager**

```C#
LocalizationManager.Manager = new LocalizationManager()
{
    ResourceManager = MyRadImageEditorResources.ResourceManager
};
```

> tip You can download a runnable project of the previous example from our online SDK repository: [Localization](https://github.com/telerik/xaml-sdk/tree/master/ImageEditor/Localization).

## Localization Using Custom Localization Manager

**Telerik.Windows.Controls.LocalizationManager** allows you to easily localize any of the Telerik controls. To apply custom localization to your controls, just instantiate your custom **LocalizationManager** deriving from the LocalizationManager object and set it to the static property **LocalizationManager.Manager** before the creation of the UI.

**Create custom LocalizationManager**

```C#
LocalizationManager.Manager = new CustomLocalizationManager();
```

> Note that if you set the localization manager after the creation of the UI, some parts might remain not-localized.

What is left in order to fulfill the localization, is to override the method **GetStringOverride()**. The logic is pretty simple, you just have to create a switch statement and return the correct translation for each resource key. Here is an example of how you can localize some of the strings in the two SpellCheckingDialogs:

**Localize strings**

```C#
public class CustomLocalizationManager : LocalizationManager
{
    public override string GetStringOverride(string key)
    {
        switch (key)
        {
            case "ImageEditor_Resize":
                return "New Resize";
            case "ImageEditor_CanvasResize":
                return "New Canvas Resize";
            case "ImageEditor_Rotate90":
                return "New Rotate at 90";
            case "ImageEditor_Rotate180":
                return "New Rotate at 180";
            case "ImageEditor_Rotate270":
                return "New Rotate at 270";
            case "ImageEditor_RoundCorners":
                return "New Round Corners";
            case "ImageEditor_FlipHorizontal":
                return "New Flip Horizontal";
            case "ImageEditor_FlipVertical":
                return "New Flip Vertical";
            case "ImageEditor_Crop":
                return "New Crop";
                //...
        }
        return base.GetStringOverride(key);
    }
}
```

Of course, if you don't want to hard-code your translation inside the source code, you can always use resource files.

**Localization using resource files**

```C#
public override string GetStringOverride(string key)
{
    switch (key)
    {
        //----------------------
        case "ImageEditor_Resize":
            return MyRadImageEditorResources.ImageEditor_Resize;
            //----------------------
    }

    return base.GetStringOverride(key);
}
```

### Changing the Image Preview Label

In the WPF **RadImageEditorUI**, the image preview label uses the **ImageEditor_ImagePreview** resource key. Override this key in your custom localization manager to change the label:

```csharp
using Telerik.Windows.Controls;

public class ImageEditorLocalizationManager : LocalizationManager
{
    public override string GetStringOverride(string key)
    {
        switch (key)
        {
            case "ImageEditor_ImagePreview":
                return "Photo Preview";
            default:
                return base.GetStringOverride(key);
        }
    }
}
```

In your application constructor, set the custom manager before calling **InitializeComponent()** so it is available when the UI is created:

```csharp
public App()
{
    LocalizationManager.Manager = new ImageEditorLocalizationManager();
    InitializeComponent();
}
```

**LocalizationManager.Manager** is a static property, so this override changes the preview label for all **RadImageEditorUI** instances that use this manager. To change the label for only one instance, customize its control template.

## See Also

* [Localization SDK Example](https://github.com/telerik/xaml-sdk/tree/master/ImageEditor/Localization)
* [RadImageEditorUI](https://www.telerik.com/products/wpf/documentation/controls/radimageeditor/features/radimageeditorui)
