Localization - harborsiem/WinForms-Ribbon GitHub Wiki

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. One can do it easily by uncomment #define german

//#define german
//comment or uncomment line before to change language

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

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

Localized by German culture

Localization7

⚠️ **GitHub.com Fallback** ⚠️