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);
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.)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…