Skip to content

Localization

harborsiem edited this page Apr 29, 2024 · 4 revisions

Localization

Add Ribbon XAML(RibbonMarkup.xml) and Localization Files (RibbonMarkup.resx)

For more details about Ribbon XAML, look at MSDN or the Samples mentioned above.

Localization1

  1. The localization information for the Ribbon text. The file name must be equal to the Ribbon XAML file
  2. The Ribbon XAML file
  3. The Ribbon embedded resource generated by custom build tool
  4. The Ribbon log file generated by custom build tool
  5. The custom build tool name to generate *3 and *4

How Localization Works

Ribbon UI information must be defined in the Ribbon XAML file and localization information in the ResX file. The custom tool is searching for "{Resource" tags in the XAML file and replacing it using information from ResX file. Multiple ..ribbon files are generated - one for each ResX file. All these ..ribbon files have to set to Embedded Resources in the Build Property of your project.

Define localized text inside Ribbon XAML using {Resource:} notation.

Localization2

Add localized resources to ResX file

Localization3

Specify the Ribbon UI in the Ribbon control properties

In the properties of the Ribbon control, we must specify the default or neutral ".ribbon" file generated by the RibbonTools build tool (RibbonTools.exe). All “*.ribbon” files must be an embedded resource in your application. You can find them in the folder of your Ribbon XAML file.

Localization4

Result looks like...

Let's see how the result looks like. In our sample, we have two Ribbon resources: Default and German.

Localized by default culture

Localization5

Specify culture information

In order to use a localized Ribbon, the application's current culture must be set by changing the CurrentCulture property of the current thread.

namespace _19_Localization
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("de-DE");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("de-DE");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

Localization6

Localized by German culture

Localization7

Table of contents

Clone this wiki locally