Community
    • Login
    1. Home
    2. Popular
    Log in to post
    • All Time
    • Day
    • Week
    • Month
    • All Topics
    • New Topics
    • Watched Topics
    • Unreplied Topics
    • All categories
    • W

      The problem with notepad.runMenuCommand

      Watching Ignoring Scheduled Pinned Locked Moved General Discussion
      6
      1 Votes
      6 Posts
      174 Views
      PeterJonesP

      @westyles,

      I was very confused by your replies, until I reread the exact phrasing of your original I think that “menuId” or “Id” should be used here. (Some of my confusion may have been while hopping back and forth between what you said in the Issue and what you said here, and getting my wires crossed as a result.)

      I had interpreted the "Id" in that sentence to be equivalent to commandID in my mind… but I now believe I had misinterpreted that. And I can see that my insistence that using the commandID integer is really easy would be confusing and frustrating for you.

      I don’t know what you meant by that "Id" as distinct from menuId, but I will reply on the menuId portion of that suggestion: Notepad++ does not give plugins direct access to the internal translation table it uses for localization. So the PythonScript plugin has no way of knowing, by asking Notepad++, what the underlying menuId string is for a given menu name. So there is no way that PythonScript could give you a function that uses the menuId internal strings instead of the strings displayed in the active menu localization, sorry.

      Most scripts for PythonScript are for a single user, or distributed across a single organization in a corporate setting, so my guess is that most people have just written their scripts with a single localization in mind, and not bothered trying to make it more “generic” than that. If you are writing scripts for multi-localization needs, then I can see why this would be frustrating.

      That said, hardcoding the translation for the Language menu name is fragile, at best – it will only work until someone decides that there’s a better spelling word for that menu in a given language, or until another localization is added to Notepad++'s distribution. What I might suggest, instead:

      create a string like themepath = notepad.getNppDir() + "\\localization\\" + notepad.getNativeLangFileName() , then use import xml.etree.ElementTree to parse that file, to be able to extract the actual <Item menuId="language" name="&amp;Language"/>
    • donhoD

      Notepad++ v8.9.1 Release Candidate

      Watching Ignoring Scheduled Pinned Locked Moved Announcements
      1
      1 Votes
      1 Posts
      14 Views
      No one has replied
    • J

      Perl keywords "class" and "method" not recognised by Function List

      Watching Ignoring Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
      12
      0 Votes
      12 Posts
      474 Views
      J

      @PeterJones I am happy :)