1. <i id='oo0yZ'><tr id='oo0yZ'><dt id='oo0yZ'><q id='oo0yZ'><span id='oo0yZ'><b id='oo0yZ'><form id='oo0yZ'><ins id='oo0yZ'></ins><ul id='oo0yZ'></ul><sub id='oo0yZ'></sub></form><legend id='oo0yZ'></legend><bdo id='oo0yZ'><pre id='oo0yZ'><center id='oo0yZ'></center></pre></bdo></b><th id='oo0yZ'></th></span></q></dt></tr></i><div id='oo0yZ'><tfoot id='oo0yZ'></tfoot><dl id='oo0yZ'><fieldset id='oo0yZ'></fieldset></dl></div>
      • <bdo id='oo0yZ'></bdo><ul id='oo0yZ'></ul>

      <small id='oo0yZ'></small><noframes id='oo0yZ'>

      <legend id='oo0yZ'><style id='oo0yZ'><dir id='oo0yZ'><q id='oo0yZ'></q></dir></style></legend>
        <tfoot id='oo0yZ'></tfoot>

      1. 根据办公产品的语言本地化 VSTO 插件

        时间:2023-08-25
          <bdo id='lzCQo'></bdo><ul id='lzCQo'></ul>
              <tbody id='lzCQo'></tbody>
              <i id='lzCQo'><tr id='lzCQo'><dt id='lzCQo'><q id='lzCQo'><span id='lzCQo'><b id='lzCQo'><form id='lzCQo'><ins id='lzCQo'></ins><ul id='lzCQo'></ul><sub id='lzCQo'></sub></form><legend id='lzCQo'></legend><bdo id='lzCQo'><pre id='lzCQo'><center id='lzCQo'></center></pre></bdo></b><th id='lzCQo'></th></span></q></dt></tr></i><div id='lzCQo'><tfoot id='lzCQo'></tfoot><dl id='lzCQo'><fieldset id='lzCQo'></fieldset></dl></div>

                <small id='lzCQo'></small><noframes id='lzCQo'>

              1. <legend id='lzCQo'><style id='lzCQo'><dir id='lzCQo'><q id='lzCQo'></q></dir></style></legend>

                  <tfoot id='lzCQo'></tfoot>
                1. 本文介绍了根据办公产品的语言本地化 VSTO 插件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一个 VSTO 插件,并希望根据办公产品的语言版本对其进行本地化.理论上是这样的:

                  I'm developing a VSTO addin and want it to be localized according to the language version of the office product. In theory, that's how to do it:

                  int lcid = Application.LanguageSettings.get_LanguageID(Office.MsoAppLanguageID.msoLanguageIDUI);
                  System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lcid);
                  

                  为此,我当然需要初始化 Application.因此,我可以执行此代码的最早点是在 Startup 事件处理程序中.然而,此时 CreateRibbonExtensibilityObject() 已经被调用,所以至少我的自定义功能区选项卡的标题将以 Windows 语言显示,这可能会有所不同.在功能区类中,我有一个 onLoad 事件的处理程序,我在其中存储 IRibbonUI 的一个实例以供以后使用.我可以将此实例交给插件类并让它调用 IRibbonUI.Invalidate() .但这似乎有点奇怪 - 创建一个功能区只是为了在几微秒后使其无效.所以我想知道 - 并在这里询问 - 是否有更优雅的方式来根据办公产品的语言版本本地化 vsto 插件的功能区.

                  For this to work I need Application to be initialized, of course. So the earliest point where I can execute this code is in the Startup event handler. At this point, however, CreateRibbonExtensibilityObject() already has been called, so at least the title of my custom ribbon tab is going to be displayed in the Windows language, which might be different. In the ribbon class I have a handler for the onLoad event, where I store an instance of IRibbonUI for later use. I could hand over this instance to the addin class and let it call IRibbonUI.Invalidate() on it. But this seems to be a bit strange - creating a ribbon just to invalidate it a couple of microseconds later. So I wonder - and ask here - whether there is a more elegant way to localize the ribbon of a vsto addin according to the language version of the office product.

                  (我见过 这个类似的问题,但是那里提供的方法这个答案对我来说看起来更糟.)

                  (I've seen this similar question, but the approach offered there by this answer looks even worse to me.)

                  推荐答案

                  您始终可以覆盖 CreateRibbonExtensibilityObject 方法或可能覆盖其他一些 AddInBase 方法(BeginInit、Initialize 等)挂钩到加载项加载中的正确位置生命周期.

                  You can always override the CreateRibbonExtensibilityObject method or possibly override some of the other AddInBase methods (BeginInit, Initialize, etc.) to hook into the proper location in the AddIn load lifecycle.

                  我之前重写了 CreateRibbonExtensibilityObject 以确保在加载功能区之前运行初始化代码.我注意到 CreateRibbonExtensibilityObjectStartup 事件是随机触发的.有时 Startup 先发生 - 有时 CreateRibbonExtensibilityObject 先触发.我必须手动同步这两个事件,以确保在创建功能区之前执行任何初始化代码.如果 CreateRibbonExtensibilityObject 先触发 - Application 对象尚未创建.

                  I have overridden the CreateRibbonExtensibilityObject before to ensure that initialization code is run before the Ribbon is loaded. I have noticed that CreateRibbonExtensibilityObject and Startup events are triggered at random times. Sometimes Startup happens first - sometimes CreateRibbonExtensibilityObject fires first. I had to manually synchronize the two events to ensure any initialization code is executed prior to Ribbon creation. If CreateRibbonExtensibilityObject fires first - the Application object has not yet been created.

                   Outlook.Application app = this.GetHostItem<Outlook.Application>(typeof(Outlook.Application), "Application");
                   int lcid = app.LanguageSettings.get_LanguageID(Office.MsoAppLanguageID.msoLanguageIDUI);
                   Thread.CurrentThread.CurrentUICulture = new CultureInfo(lcid);
                  

                  这将为您检索对 Application 实例的引用 - 无论它是否已加载到 Initialize 中.

                  This will retrieve a reference to the Application instance for you - regardless if it has been loaded in the Initialize yet.

                  这篇关于根据办公产品的语言本地化 VSTO 插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:获取本地化路径的功能? 下一篇:Asp.net core Localization 总是返回英语文化

                  相关文章

                  最新文章

                  <small id='c5wMG'></small><noframes id='c5wMG'>

                    • <bdo id='c5wMG'></bdo><ul id='c5wMG'></ul>

                    <tfoot id='c5wMG'></tfoot>
                    <i id='c5wMG'><tr id='c5wMG'><dt id='c5wMG'><q id='c5wMG'><span id='c5wMG'><b id='c5wMG'><form id='c5wMG'><ins id='c5wMG'></ins><ul id='c5wMG'></ul><sub id='c5wMG'></sub></form><legend id='c5wMG'></legend><bdo id='c5wMG'><pre id='c5wMG'><center id='c5wMG'></center></pre></bdo></b><th id='c5wMG'></th></span></q></dt></tr></i><div id='c5wMG'><tfoot id='c5wMG'></tfoot><dl id='c5wMG'><fieldset id='c5wMG'></fieldset></dl></div>

                      <legend id='c5wMG'><style id='c5wMG'><dir id='c5wMG'><q id='c5wMG'></q></dir></style></legend>