Localization depn of Office UI

Add-in Express™ Support Service
That's what is more important than anything else

Localization depn of Office UI
 
Subscribe
Daniel Lutz




Posts: 5
Joined: 2023-02-27
Hello Addin Express team,

what is the best way of support localization of an addin express adinn depend of the office ui. I know that
Application.LanguageSettings
it is possible to evaluate the office ui language and i also know that i can set it to the
CurrentThread.CultureUI
but the loading mechanism of the ribbon is a bit tricky.

The addin itself create c# objects (ADX buttons, tabs and so on) with captions related in
InitializeComponent()
of the addin constructor. This use the
CurrentUI
property of the
ResourceManager
to choose the right localized value. In the constructor the
Application
property is not initialzed. I`ve also check the
OnBeforeRobbonLoad
mechanism to load initialize the value but same problem here.

So is there any way to retrieve the information set it to the
CurrentThread
properties bevor the ribbon is created?

best regards
Posted 24 Sep, 2024 11:24:05 Top
Dmitry Kostochko


Add-in Express team


Posts: 2887
Joined: 2004-04-05
Hello Daniel,


what is the best way of support localization of an addin express adinn depend of the office ui.


I am afraid there is no common "best way", each developer chooses their own way and decides that the one they chose is the best :)


Please have a look at the following search results, this issue has already been discussed:
https://www.add-in-express.com/search-addin.php?q=localization&filter=inforums-NET&by=relevance


Here I will try to describe one of possible ways on a simple Excel add-in example:
1. Open the designer of your AddinModule.
2. In the Properties window, set the Localizable property to True.
3. In the Properties window, choose another language (e.g. Spanish) in the Language property.
4. Update all captions of all components (Ribbon tabs, groups, buttons, etc.).
5. Handle the OnRibbonBeforeCreate event:


private void AddinModule_OnRibbonBeforeCreate(object sender, string ribbonId)
{
    int culture = ExcelApp.LanguageSettings.LanguageID[Office.MsoAppLanguageID.msoLanguageIDUI];
    CultureInfo ci = new CultureInfo(culture);
    //MessageBox.Show("OnRibbonBeforeCreate " + ci.ToString());
    switch (ci.ThreeLetterISOLanguageName)
    {
        case "spa": // Spanish
            this.ApplyResources(ci);
            break;
        case "pol": // Polish
            this.ApplyResources(ci);
            break;
        default:
            // do nothing, use default English
            break;
    }
}

private void ApplyResources(CultureInfo cultureInfo)
{
    System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AddinModule));

    resources.ApplyResources(this.adxRibbonTab1, "adxRibbonTab1", cultureInfo);
    resources.ApplyResources(this.adxRibbonGroup1, "adxRibbonGroup1", cultureInfo);
    resources.ApplyResources(this.adxRibbonButton1, "adxRibbonButton1", cultureInfo);
    resources.ApplyResources(this.adxRibbonButton2, "adxRibbonButton2", cultureInfo);
    resources.ApplyResources(this.adxRibbonButton3, "adxRibbonButton3", cultureInfo);
    resources.ApplyResources(this, "$this");

}



Hope this description will help you. If you wish, I can send you the complete test project by email.
Posted 24 Sep, 2024 15:36:36 Top
Daniel Lutz




Posts: 5
Joined: 2023-02-27
That helps a lot.

Thank you very much.

Best regards Daniel
Posted 24 Sep, 2024 18:01:48 Top