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

Localization

Localization Using ResourceManager

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 ribbon bar into English, German and Dutch. For that purpose you will have to add three new resource files to your project:

  • RibbonResources.resx - this resource file will store the English(default) resources for the ribbon bar control. Set the AccessModifier property to Public.

  • RibbonResources.de.resx - this resource file will store the German resources for the ribbon bar control. Set the AccessModifier property to No code generation.

  • RibbonResources.nl.resx - this resource file will store the Dutch resources for the ribbon bar control. Set the AccessModifier property to No code generation.

WPF RadRibbonView Localization Files

Now, having the needed files, it's time to illustrate the idea and localize for example the 'Minimize the Ribbon', 'Customize Quick Access Tool bar' and 'Show below the Ribbon' strings. For that purpose you need to create three resource strings in each one of the three resource files and translate them to the appropriate language.

Note that the name of the resource string should be the same as the resource key for the string you are localizing i.e. the resource key for 'Minimize the Ribbon' is RibbonBarQATMinimize, for 'Customize Quick Access Tool bar' is RibbonBarQATCustomize and for 'Show below the Ribbon' is RibbonBarQATShowBelow.

The snapshot below shows the content of the RibbonViewResources.de.resx file. The resource name of the other two files should be the same. Only the Value column will contain the translation for the appropriate language.

Rad Ribbon View-Localization-Resource File

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

LocalizationManager.Manager = new LocalizationManager() 
{ 
ResourceManager = RibbonResources.ResourceManager 
}; 
LocalizationManager.Manager = New LocalizationManager() 
LocalizationManager.Manager.ResourceManager = RibbonResources.ResourceManager 

If you rely on culture settings to load the right resources automatically, you have to write some code inside your application's project file. For example, if you have to support English and Dutch languages, you can store the localized strings in RibbonResources.resx and RibbonResources.nl.resx files. For the RibbonResources.resx file you can set ResXFileCodeGenerator to Internal or Public and for others to No code generation. Then, open the project file in a text-mode and insert the code below into the section. In this way you notify the framework about the supported cultures.

<SupportedCultures>en;nl</SupportedCultures>                

Localization Using Custom Localization Manager

The other way to localize your RadRibbonView control is to create a class that derives from the LocalizationManager object and to override its method GetStringOverride(). The logic is pretty simple, you just have to create a switch statement and return the correct translation for each resource key, as it is shown below:

public class CustomLocalizationManager : LocalizationManager 
{ 
    public override string GetStringOverride( string key ) 
    { 
        switch( key ) 
        { 
            case "RibbonViewQATMinimize": 
                return "Minimieren der Multifunktionsleiste"; 
            case "RibbonViewQATCustomize": 
                return "Anpassen Sie die Symbolleiste"; 
            case "RibbonViewQATShowBelow": 
                return "Zeigen unten die Multifunktionsleiste"; 
        } 
        return base.GetStringOverride( key ); 
    } 
} 
Public Class CustomLocalizationManager 
    Inherits LocalizationManager 
    Public Overloads Overrides Function GetStringOverride(ByVal key As String) As String 
        Select Case key 
                Case "RibbonViewQATMinimize" 
                    Return "Minimieren der Multifunktionsleiste" 
                Case "RibbonViewQATCustomize" 
                    Return "Anpassen Sie die Symbolleiste" 
                Case "RibbonViewQATShowBelow" 
                    Return "Zeigen unten die Multifunktionsleiste" 
            End Select 
 
        Return MyBase.GetStringOverride(key) 
    End Function 
End Class 

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

public override string GetStringOverride( string key ) 
{ 
    switch( key ) 
    { 
        case "RibbonViewQATMinimize": 
            return RibbonBarResources.RibbonBarQATMinimize; 
    } 
    return base.GetStringOverride( key ); 
} 
Public Overloads Overrides Function GetStringOverride(ByVal key As String) As String 
    Select Case key 
            Case "RibbonViewQATMinimize" 
                Return RibbonBarResources.RibbonBarQATMinimize 
        End Select 
    Return MyBase.GetStringOverride(key) 
End Function 

RadRibbonView Resource Keys

Here is a list of all of the Resources Keys available and their default values:

Key Value
RibbonViewGalleryButtonMore More
RibbonViewGalleryButtonUpDown Row
RibbonViewGalleryOfPart of
RibbonViewQATCustomize Customize Quick Access ToolBar
RibbonViewQATMinimize Minimize the Ribbon
RibbonViewQATShowAbove Show above the Ribbon
RibbonViewQATShowBelow Show below the Ribbon
RibbonViewQATRestore Restore the Ribbon
RibbonViewWindowTitleDivider -
RibbonWindowClose Close
RibbonWindowMaximize Maximize
RibbonWindowMinimize Minimize
RibbonWindowRestoreDown Restore Down
RibbonViewExpandRibbon Expand the Ribbon
RibbonViewHelp Help
RibbonViewLayoutModeButtonContent Simplified Ribbon

See Also

In this article