# Custom Localization

## Content

Custom localization in WPF lets developers use their own translations for C1 libraries without changing code or contacting C1 Support. It embeds user resource files into the application, allowing full control over text display and overriding default translations.

### Key features include:

* **Full Control:** Manage and maintain translations internally without relying on external updates from C1
* **Support for New Languages:** Localize user app into languages that C1 does not officially support
* **Improved User Experience:** Translate to fit user’s brand tone or region-specific terminology
* **No Code Required:** Use correctly named .resx files as embedded resources instead of codes
* **Seamless Integration:** The **ResourceBase\<R>** class in **C1.WPF.Core** automatically prioritizes user’s resources at runtime, and falls back to default translations when needed. Most WPF resource classes now inherit from it, except:
    * C1Scheduler
    * C1GanttView
    * FlexChart
    * Barcode
    * Document
    * FlexReport

## Add New Language

This section demonstrates how users can add languages not supported by C1 localization using FlexGrid as a example.

### Create Sample FlexGrid

1. Create a FlexGrid following the step in this guide: [<span class="_19itglyw _vchhusvi _r06hglyw" style="border: none; box-sizing: border-box; appearance: none;">Quick Start</span>](https://developer.mescius.com/componentone/docs/wpf/online-flexgrid/FlexGridQuickStart#add-flexgrid-control-to-wpf-core-application)
2. Copy the following code into your application to include the sample data referenced throughout this guide.

```auto
flexGrid.ItemsSource = new[]
{
     new { ID = 1, Name = "Anna", City = "Budapest" },
     new { ID = 2, Name = "Béla", City = "Győr" },
     new { ID = 3, Name = "Csilla", City = "Debrecen" }
 };
```

### Locate Default Resource Files

Default resources files (in this case, of FlexGrid) can be found in:
**C1ControlPanel**: C:\\Program Files (x86)\\MESCIUS\\ComponentOne\\WPF\\Resources
**NuGet**: "C:\\Users\\%userprofile%\\.nuget\\packages\\c1.wpf.grid\\9.0.20252.1167\\lib\\net6.0-windows7.0

>type=info
> If downloaded through NuGet, the C1.WPF.Grid.dll file containing resources files is used. Expand the Resources section within the DLL, then extract and save the files following the original folder structure.

Example of the resource files:

```auto
Resources.resx        (default English)
Resources.ja.resx     (Japanese)
Resources.zh-Hans.resx (Simplified Chinese)
```

### Create a New Translation File

1. In Solution Explorer, recreate the folder structure that matches the ComponentOne assembly where the resource resides. For **C1FlexGrid**, this structure is typically:
    * `[Project Root]`
        * ``` C1.``<span data-testid="definition-highlighter" class="_5pioz8co _189e1dm9 _1il9buyh _19lc184f _d0altlke" style="border-image: linear-gradient(90deg, rgb(0, 101, 255), rgb(191, 99, 243), rgb(245, 230, 168)) 0 0 100% / 1 / 0 stretch; border-width: 0px 0px 2px; border-bottom-style: solid; --_11qfq0e: solid;">WPF</span>``.Grid ``` (Subfolder)
            * `Resources` (Subfolder containing the .resx files)

![33995634-c0c8-4b78-a8ec-afd9393b7297.png](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/33995634-c0c8-4b78-a8ec-afd9393b7297.483749.png)

2. Drag and drop the default English (.resx) file from C1 libraries to **Resources** and change the culture suffix to match the culture
3. Select each .resx file and set its Build Action to EmbeddedResource
4. Translate all strings into your target language (e.g. Dzongkha) as show in the image below.

![f1edc0a3-b21f-44ce-99a3-8a68bfd17daa.jpg](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/f1edc0a3-b21f-44ce-99a3-8a68bfd17daa.b2a053.jpg?width=500)

>type=info
> Maintain the same folder structure as the default C1 resource files. Alternatively, if all files are kept in a single folder, rename the file to include the full namespace, e.g.:
> C1.WPF.Grid.Resources.Resources.hu.resx

### Set Culture of Application

In App.xaml.cs, set the application’s culture to Dzongkha using the following code.

```auto
 var culture = new CultureInfo("dz-DZ");
 Thread.CurrentThread.CurrentCulture = culture;
 Thread.CurrentThread.CurrentUICulture = culture;
 InitializeComponent();
```

### Build and Verify

The end result will use the new language added by user, in this case, Dzongkha.
![f1d367f1-e9c4-4d8f-8750-8fae75c652cf.png](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/f1d367f1-e9c4-4d8f-8750-8fae75c652cf.6acb7c.png)

## Override existing translation

This section demonstrates how users can edit translations of language supported by C1 localization using FlexGrid and Russian (ru) as a example.

### Add Target Language

1. In Solution Explorer, create a file path imitating the image below:

![60011d4f-d8a1-49e1-9615-6fd6611b564a.png](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/60011d4f-d8a1-49e1-9615-6fd6611b564a.3ff3b9.png)

2. Drag and drop the Russian (.resx) file from C1 libraries
3. Select the .resx file and set its Build Action to EmbeddedResource

### Update Translation

In the .resx file, adjust any translations that requires improvement.
![28e78fdf-3262-4284-867d-2026ccf9a5f2.png](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/28e78fdf-3262-4284-867d-2026ccf9a5f2.2b93ad.png?width=500)
**Build and Verify**
The end result will use the updated language adjusted by user.
![adffd712-5622-4131-97c0-5e3932bac9b7.png](https://cdn.mescius.io/document-site-files/images/de6bd900-fc60-46ca-ad9b-dbc4f177a74f/adffd712-5622-4131-97c0-5e3932bac9b7.1f8556.png?width=500)

<br>
<br>
<br>
