New to Telerik UI for WPF? Download free 30-day trial

Extract the Default Telerik Localization Resources

Environment

Product Version 2023.3.1010
Product UI for WPF

Description

How to extract the default Telerik .resx files containing the localization strings and save them to files. This will allow you to replace values from the original files and extend the localization with a new language.

An alternative approach than the one shown in this topic is to create a custom LocalizationManager and override its GetStringOverride method, as shown in the Localization article.

Solution

The Telerik's default .resx files can be accessed by loading the Telerik.Windows.Controls Assembly and then creating a new ResourceManager that loads resource file by name. Then, you can read the resources for the different cultures and save them in new .resx files.

To create new .resx files, you can use the ResXResourceWriter class from the System.Windows.Forms assembly.

private void ExtractTelerikDefaultLocalizationResources() 
{             
    string newResourceFileNameFormat = @".\TelerikStrings{0}.resx"; 
    string defaultLanguageTag = "us-US"; 
    var supportedCultures = new List<CultureInfo>() 
    { 
        new CultureInfo(defaultLanguageTag), 
        new CultureInfo("de-DE"), 
        new CultureInfo("es-ES"), 
        new CultureInfo("fr-FR"), 
        new CultureInfo("it-IT"), 
        new CultureInfo("nl-NL"), 
        new CultureInfo("tr-TR"), 
    }; 
 
    var telerikAssembly = Assembly.Load("Telerik.Windows.Controls"); 
    var resourceManager = new ResourceManager("Telerik.Windows.Controls.Strings", telerikAssembly); 
 
    foreach (CultureInfo culture in supportedCultures) 
    { 
        ResourceSet resourceSet = resourceManager.GetResourceSet(culture, true, true); 
        string languageTag = culture.IetfLanguageTag != defaultLanguageTag ? "." + culture.IetfLanguageTag.Substring(0, 2) : string.Empty; 
        string resourceFileName = string.Format(newResourceFileNameFormat, languageTag); 
 
        using (ResXResourceWriter resx = new ResXResourceWriter(resourceFileName)) 
        { 
            foreach (DictionaryEntry res in resourceSet) 
            { 
                resx.AddResource(res.Key.ToString(), res.Value); 
            } 
        } 
    } 
} 

See Also

In this article