Community
    • Login

    The problem with notepad.runMenuCommand

    Scheduled Pinned Locked Moved General Discussion
    3 Posts 2 Posters 87 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • W
      westyles
      last edited by

      I created an issue: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/17164
      but it was closed. Then I added more details—I made a screen recording of the problem.
      There is a problem with any language other than EN.

      And I found a discussion thread on the same issue:
      https://sourceforge.net/p/npppythonscript/discussion/1188886/thread/bc080292/

      And I realized that it was because of nativeLang.xml
      The essence of the problem is that the command:
      notepad.runMenuCommand(menuName, menuOption) for menuName does not use “menuId”,
      and “name” from the xml string: <Item menuId=“language” name=“&Language”/>
      Which varies depending on the language npp! And it turns out that the command is not universal!

      Usually, universal commands are used for this, and I think that “menuId” or “Id” should be used here!
      Then no one will have any problems writing code.

      I decided to write on the forum because I found a solution to get around this, given the situation, and before calling the command, I substitute the necessary current translation as follows:

      langID_dict = {'abkhazian.xml': 'Асинтаксисқәа', 'afrikaans.xml': 'Taal', 'albanian.xml': 'Gjuha', 'arabic.xml': 'لغة',
      'aragonese.xml': 'Luengache', 'aranese.xml': 'Lenguatge', 'azerbaijani.xml': 'Dil', 'basque.xml': 'Hizkuntza',
      'belarusian.xml': 'Сінтаксіс', 'bengali.xml': 'ভাষা', 'bosnian.xml': 'Jezik', 'brazilian_portuguese.xml': 'Linguagem',
      'breton.xml': 'Yezh', 'bulgarian.xml': 'Синтаксис', 'catalan.xml': 'Llenguatge', 'chineseSimplified.xml': '语言(L)',
      'corsican.xml': 'Linguaghju', 'croatian.xml': 'Sintakse', 'czech.xml': 'Syntaxe', 'danish.xml': 'Sprog',
      'dutch.xml': 'Syntaxis', 'english.xml': 'Language', 'english_customizable.xml': 'Language', 'esperanto.xml': 'Lingvaĵo',
      'estonian.xml': 'Keel', 'extremaduran.xml': 'Luenga', 'farsi.xml': 'زبان', 'finnish.xml': 'Koodikieli',
      'french.xml': 'Langage', 'friulian.xml': 'Lengaç', 'galician.xml': 'Linguaxe', 'georgian.xml': 'სინტაქსი',
      'german.xml': 'Sprache', 'greek.xml': 'Γλώσσα', 'gujarati.xml': 'ભાષા', 'hebrew.xml': 'שפה',
      'hindi.xml': 'भाषा', 'hongKongCantonese.xml': '語言(L)', 'hungarian.xml': 'Nyelv', 'indonesian.xml': 'Bahasa',
      'irish.xml': 'Teanga', 'italian.xml': 'Linguaggio', 'japanese.xml': '言語(L)', 'kabyle.xml': 'Tameslayt',
      'kannada.xml': 'ಲ್ಯಾಂಗ್ವೇಜ್', 'kazakh.xml': 'Бағдарламалық тіл', 'korean.xml': '언어(L)', 'kurdish.xml': 'زمانەكان',
      'kyrgyz.xml': 'Синтаксис', 'latvian.xml': 'Valoda', 'ligurian.xml': 'Lengoaggio', 'lithuanian.xml': 'Kalba',
      'luxembourgish.xml': 'Sprooch', 'macedonian.xml': 'Јазик', 'malay.xml': 'Bahasa', 'marathi.xml': 'भाषा',
      'mongolian.xml': 'Хэл', 'nepali.xml': 'भाषा', 'norwegian.xml': 'Språk', 'nynorsk.xml': 'Språk',
      'occitan.xml': 'Lengatge', 'piglatin.xml': 'Anguagelay', 'polish.xml': 'Składnia', 'portuguese.xml': 'Linguagem',
      'punjabi.xml': 'ਭਾਸ਼ਾ', 'romanian.xml': 'Limbaj', 'russian.xml': 'Синтаксисы', 'samogitian.xml': 'Shnekta',
      'sardinian.xml': 'Limbàgiu', 'serbian.xml': 'Jezik', 'serbianCyrillic.xml': 'Језик', 'sinhala.xml': 'භාෂාව',
      'slovak.xml': 'Jazyk', 'slovenian.xml': 'Sintaksa jezika', 'spanish.xml': 'Lenguaje', 'spanish_ar.xml': 'Lenguaje',
      'swedish.xml': 'Språk', 'tagalog.xml': 'Wika', 'taiwaneseMandarin.xml': '語言(L)', 'tajikCyrillic.xml': 'Забон',
      'tamil.xml': 'மொழி (L)', 'tatar.xml': 'Синтакслар', 'telugu.xml': 'ల్యాంగ్వేజ్ (L)', 'thai.xml': 'ภาษา (L)',
      'turkish.xml': 'Diller', 'ukrainian.xml': 'Мова', 'urdu.xml': 'پروگرامنگ زبان', 'uyghur.xml': 'پروگرامما تىلى',
      'uzbek.xml': 'Sintaksislar', 'uzbekCyrillic.xml': 'Синтаксис', 'venetian.xml': 'Ƚenguagio', 'vietnamese.xml': 'Ngôn ngữ',
      'welsh.xml': 'Iaith (L)', 'zulu.xml': 'ulimi'}
      
      _file_lang = notepad.getNativeLangFileName()
      notepad.runMenuCommand(langID_dict[_file_lang], '222')
      
      PeterJonesP 1 Reply Last reply Reply Quote 1
      • PeterJonesP
        PeterJones @westyles
        last edited by PeterJones

        To begin with: I like your workaround script. It’s a great thing to share, which is why I upvoted it. (I am saying this, so that you don’t take my further comments as a criticism of this script)

        @westyles said in The problem with notepad.runMenuCommand:

        I created an issue: https://github.com/notepad-plus-plus/notepad-plus-plus/issues/17164
        but it was closed.

        Because it was missing essential details for any Notepad++ bug report. Namely, it did not include the steps to reproduce, nor did it include the ?-menu’s Debug Info that every issue requests that you include. Based on this lack of information, the developer could not replicate your problem, and thus closed the issue. (But more on this in a bit)

        Then I added more details—I made a screen recording of the problem.

        But a screen recording is not necessarily sufficient to show the steps to reproduce, clicking on links to random upload websites is foolish (so i wouldn’t expect anyone to click to your random “video” – please note, such websites would allow you to upload malicious content and claim it’s a video), and you didn’t include the requested details.

        And I found a discussion thread on the same issue:

        Notice where that discussion was: in the NppPythonScript plugin repo for the old 2016-era version of the PythonScript plugin. That plugin has a new home and a new maintainer/developer. If you want a feature request or bug report for the PythonScript plugin, you would need to go to the https://github.com/bruderstein/pythonscript repo. But this is neither a bug, nor does a feature need to be added

        And this is not a bug. The notepad.runMenuCommand() interface is well established as being based on the name of the menu item. It literally searches the underlying win32 menu objects looking for matching text. If you want a new command that runs it based on menuCommand-ID, you could request that (if it didn’t already exist). But note, that’s precisely what notepad.menuCommand() does – it “Runs a Notepad++ menu command. Use the MENUCOMMAND enum, or integers directly from the nativeLang.xml file.” So if you want to use Command ID, then use notepad.menuCommand(). If you want to use the name of the command, use notepad.runMenuCommand().

        W 1 Reply Last reply Reply Quote 2
        • W
          westyles @PeterJones
          last edited by

          @PeterJones said in The problem with notepad.runMenuCommand:

          And this is not a bug

          Thank you for the clarification
          I replied to you here:
          https://github.com/notepad-plus-plus/notepad-plus-plus/issues/17164#issuecomment-3762757796

          Added:
          I’ve already written to the PythonScript plugin author, and one feature has already been added at my request, under Settings:
          “DISABLE” another script is running popup warning

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors