Localization of menus and quick selection of commands for execution.
My question is - have you thought about the possibility of localization? I mean the name of the menu items added by the "addItem" and "Editor.addMenu" commands. How about adding "text_en" and / or "text_ru" to the "cfg" structure from "menu.addItem (cfg)" to build the menu according to N ++ settings? Question 2 is it possible to overload "menu.addItem (cfg)" so that it would call some function "OnAddItemToMenu (menu, cfg)" after adding a menu item. This will allow you to build a list of "cfg" items and implement quick command selection and execution accordingly. Or do I have to refactor my scripts by wrapping "menu.addItem (cfg)" in a function? What do you think?
- As I understand you want to localize the menu text. But I did not get the point how text_en which steps are necessary to make the localization. Maybe an example of cfg and next steps could help me to understand
- I like your idea to wrap the native API. I think It would open the possibility for others to extend the javascript API with functions and event emitters.
But I did not get the point how text_en which steps are necessary to make the localization. Maybe an example of cfg and next steps could help me to understand.
Let's take the default "cfg.text" - intended for English-speaking users. And "cfg.text_ru" is for Russian speakers. The "cfg.text_locale" construction - i.e. locale will indicate from which attribute to take the menu text.
var myMergeLinesIntoParagraphs = {
text: "Combine lines into paragraphs\tCtrl+Shift+A",
text_ru: "Объедините строки в абзацы\tCtrl+Shift+A",
ctrl: true,
shift: true,
alt: false,
key : 0x41,
cmd: MergeLinesIntoParagraphs
}
vTextSubMenu.addItem(myMergeLinesIntoParagraphs);
And a refactoring request, in: Menu.addItem (); Change "addItem" to "addMenuItem" or add "addMenuItem" in API, otherwise it is difficult to search.