Click or drag to resize

Localization of Patagames WPF Controls

Localization is the process of making application multilingual by formatting the content according to the cultures. This involves configuring the application for a specific language. Culture is the combination of language and location. For example, en-US is the culture for English spoken in United States; en-GB is the culture for English spoken in Great Britain.

Patagames components support localization and have their own neutral resources. These resources can be localized as per the customer requirement, using custom .resx files and registering them via compile-time safe mechanism.

Localize WPF applications using .resx file

Changing application culture

When you are changing the application culture, then you can localize the application based on application culture by creating .resx file.

C#
public partial class Form1 : Form
{
    public Form1()
    {
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");
        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("fr-FR");
        InitializeComponent();
    }
}

Creating .resx files

You can create .resx files for any languages by following steps:

  1. Get the default resource and image files from Patagames.Pdf.Wpf.dll and Patagames.Pdf.dll/Others folders from GitHub.

  2. Right click your project and click New Folder and set name as Resources.

  3. Add a new resource file into Resources folder. You can use any custom name for your file, for example MyWpfResources.resx.

    Localization 05
  4. Now, right click on Resources folder and select Add and then New Item. In the Add New Item wizard, select Resources File option and name the file name as <your resource file name>.<culture name>.resx. For example, you can give it a name like MyWpfResources.fr-FR.resx for French culture. In the same way, add new resource files for other required cultures.

    Localization 06
  5. Now, select Add and add resource file for German culture in Resources folder.

    Localization 07
  6. Now, you can copy the key names from default resource files (downloaded from GitHub) into your custom resource file and change their corresponding values based on the culture.

    Localization 04

Registering custom resources in SDK

The SDK no longer performs dynamic runtime assembly scanning to ensure full compatibility with NativeAOT trimming. You must explicitly register your custom resource managers at the application startup using the name you gave to your resource files.

C#
// Register your custom WPF resources during application initialization before creating UI
PdfLocalizationManager.WpfV4Resources = new ResourceManager(
    "YourApplicationNamespace.Resources.MyWpfResources", 
    typeof(App).Assembly
);

Editing default culture settings

You can change the default string of any control by adding your custom .resx files to your application and assigning configured ResourceManager instances to PdfLocalizationManager. All Patagames controls safely fallback to the built-in default resources if a resource key is missing or not provided in your custom managers.

See Also