Spain
Joined: May 9, 2012
Post Count: 154
Status:
Offline
Existing menus localization
I'm trying to put a plugin's option inside an existing SH3D menu, but since the menu names change depending on the current language I don't want to use for example "Plan", because if I do so then on my SH3D on Spanish I'll have the actual "Plano" menu (which is the Spanish translation for "Plan") with all the options and then a second "Plan" menu with only my plugin's option.
So, is there some way to get at runtime the localized strings for the menu names? That way the option will appear on the intended menu regardless of the current language.
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
Spain
Joined: May 9, 2012
Post Count: 154
Status:
Offline
Re: Existing menus localization
I've seen HomeView.ActionType for the menu options, but HomePane.MenuActionType is declared as private.
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Existing menus localization
Did you have a look at the section about localization at the end of the Plug-in developer's guide? If you don't want to bother too much about this, you can use the Tools menu too.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer
Yes I did. But that allows me to localize the strings I use on my plugin, not to get the existing localized strings on the application.
Of course if I want to put my plugin option on the "3D View" menu, for example, I can just get all the translations for "3D View" from SH3D source and put them on my plugin. But the problem is that if in the future the localized string for "3D View" on some language changes, then on that language there will be two "3D View" menus, one with my localization (which coincides with the former official localization before the supposed change) and one with the new official localization.
The same problem will occur if a new language is added which is not included on the plugin: duplicated menu.
If there is a way to get the localized string at runtime then the option will always be displayed on the correct menu. If currently there is not a way to retrieve these strings, I think it's a good addition for a future release to prevent these menu duplications by the plugins.
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
This is still not at runtime, but at least with this approach you don't need to copy to your plugin all the translations of the existing menus you want to use.
Thanks Emmanuel.
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
Spain
Joined: May 9, 2012
Post Count: 154
Status:
Offline
Re: Existing menus localization
By the way, can a plugin create a new submenu to group actions, or can only create actions on a first level menu?
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
Spain
Joined: May 9, 2012
Post Count: 154
Status:
Offline
Re: Existing menus localization
Now I have a related problem.
If I change the application language the plugin menu entry remains unchanged until I close and the open the application again. Is there some way to detect the language change so I can update the option name?
---------------------------------------- If a long walk every day were healthy, mailmen would be immortal.
France
Joined: Nov 7, 2005
Post Count: 9141
Status:
Offline
Re: Existing menus localization
Listen to UserPreferences.Property.LANGUAGE property changes, and be sure to use in the listener a weak reference to your plugin to avoid memory leaks (UserPreferences instance is some kind of global variable). See ResourceAction.LanguageChangeListener for an example.
----------------------------------------
Emmanuel Puybaret, Sweet Home 3D developer