jn-npp-plugin icon indicating copy to clipboard operation
jn-npp-plugin copied to clipboard

Localization of menus and quick selection of commands for execution.

Open trdm opened this issue 5 years ago • 2 comments

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?

trdm avatar Dec 24 '20 08:12 trdm

  1. 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
  2. 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.

sieukrem avatar Dec 26 '20 20:12 sieukrem

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.

trdm avatar Dec 28 '20 14:12 trdm