- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Revit 2017.1.1
My external application (add-in) has two localizations: English (by default) and Russian. I saw that my external application (add-in) on the some computers uses wrong localization. One of that computers has the "clear" Revit without installed custom add-ins.
If I launch the revit.exe application with the /language RUS key then at this case Revit UI is Russian, but my add-in for own UI uses the default localization (i.e. "en") instead of "ru".
I extract the localized resources through the ResourcesManager class using in my code. It is the "native" way of working with resources in .NET. I know that ResourcesManager chooses the localized variant of resources on the base of Thread.CurrentThread.CurrentUICulture value.
Therefore I assumed that this value for any reason isn't "ru" or "ru-RU", despite value of the /language RUS key. I have checked the assumption and saw that I was right (look my code below): Thread.CurrentThread.CurrentUICulture property uses "en" instead of "ru". Also I see that Thread.CurrentThread.CurrentCulture uses "ru-RU" instead of "en".
Why does the /language key switch the localization not of that thread which is responsible for the user interface (UI)? Is it bug?
Result IExternalApplication.OnStartup(UIControlledApplication application) { ... // I use the `/language RUS` key for revit.exe // But I see that my add-in user the 'default' localization // instead of 'ru'. Hm... // Ok,I will check the CurrentCulture and CurrentUICulture // values... // // Oops... Localization was changed by the `/language RUS` // key, but not for that thread which shall to have this // change! Why??? CultureInfo n = Thread.CurrentThread.CurrentCulture; // ru-RU CultureInfo m = Thread.CurrentThread.CurrentUICulture; // en // I can fix this problem myself: // The CurrentUICulture switching fixes the problem, but // why such problem occurs in Revit? CultureInfo k = new CultureInfo("ru"); Thread.CurrentThread.CurrentUICulture = k; // Now my add-in uses right localization. ... }
Solved! Go to Solution.