siikamiika / yomichan-mecab-installer

Other
4 stars 8 forks source link

Edge Registry Path? #4

Closed Staz0r closed 3 years ago

Staz0r commented 3 years ago
'windows': {
        'platform_aliases': ['win32', 'cygwin'],
        'manifest_install_data': {
            'firefox': {
                'methods': ['file', 'registry'],
                'path': DIR,
                'registry_path': 'SOFTWARE\\Mozilla\\NativeMessagingHosts\\{}'.format(NAME),
            },
            'chrome': {
                'methods': ['file', 'registry'],
                'path': DIR,
                'registry_path': 'SOFTWARE\\Google\\Chrome\\NativeMessagingHosts\\{}'.format(NAME),
            },
            'chromium': {
                'methods': ['file', 'registry'],
                'path': DIR,
            },

Running the code :

1: firefox
2: chrome
3: chromium
Choose browser: 3

Using default Yomichan extension ID for chromium.
Add more extension IDs, or press enter to continue
Extension ID: //Inputted Enter
Traceback (most recent call last):
  File "D:\File-Directory\install_mecab_for_yomichan.py", line 224, in <module>
    main()
  File "D:\File-Directory\install_mecab_for_yomichan.py", line 203, in main
    manifest_install_data['registry_path'])
KeyError: 'registry_path'

Where is Edge registry_path?

jamesnicolas commented 3 years ago

You can edit the script to add edge:

In BROWSER_DATA add

    'edge': {
        'extension_id_key': 'allowed_origins',
        'extension_ids': ['chrome-extension://ogmnaimimemjmbakcfefmnahgdfhfami/'],
    },

and in PLATFORM_DATA.windows add

            'edge': {
                'methods': ['file', 'registry'],
                'path': DIR,
                'registry_path': 'SOFTWARE\\Microsoft\\Edge\\NativeMessagingHosts\\{}'.format(NAME),
            },

I was able to install it after adding this. I would make a PR but don't know what to do for linux or mac.

Staz0r commented 3 years ago

I dont know about you but the downloading stage has took me 2 hour and it is not finished yet Edit : Download finished, but Mecab test failed

Could not connect to native MeCab component
jamesnicolas commented 3 years ago

Did you confirm your registry entry got created and is pointing to the manifest file correctly? Also did you check if mecab actually works?

Staz0r commented 3 years ago

Did you confirm your registry entry got created and is pointing to the manifest file correctly? Also did you check if mecab actually works?

Where can I find the registry for the dictionary installation, and how could I check if mecab actually work?

Computer\HKEY_CURRENT_USER\SOFTWARE\MeCab

This is the only path that I could find with the value (Default) and mecabrc with the path ending in ~\Mecab\etc\mecabrc

Staz0r commented 3 years ago

Solution It turns out you need to install Mecab on C:\Program Files (x86), I installed Mecab on my D drive before, that's why it didn't work. If you happened to install Mecab outside C drive just copy and paste Mecab (Not the file and folder inside but the parent folder) folder into C:\Program Files (x86) (You don't need to change the registry path or anything for Mecab). Also if install_mecab_for_yomichan.py doesn't have your browser path set (or return erro), You need to edit the registry path which has been explained above. If you cannot locate your browser registry path, it is usually located in

Computer\HKEY_CURRENT_USER\SOFTWARE\*CompanyName*\*ProgramName*

If you cannot find NativeMessagingHosts key inside the path you should create the key yourself (Right clicking > New > Key) leave anything inside the key empty. After creating the NativeMessaggingHosts key, you should have this path set on install_mecab_for_yomichan.py.

'SOFTWARE\\*CompanyName*\\*ProgramName*\\NativeMessagingHosts{}'.format{NAME}

If everything was done correctly, Mecab test should return

Connection was successful
siikamiika commented 3 years ago

Thanks for the investigation @Staz0r and @jamesnicolas !

I've added support for Edge on Windows only in https://github.com/siikamiika/yomichan-mecab-installer/commit/e6b43b0e23f8be4a0b442959d47bd1ae25e0dfb0 so that it's hidden on other platforms.

I also improved Windows MeCab installation path guessing in https://github.com/siikamiika/yomichan-mecab-installer/commit/926d88afa4d5fdad48fdd232adf2e14c59ec7dc9 and now it should work as long as you have mecabrc in HKCU\SOFTWARE\MeCab pointing to the correct path or mecab.exe in your %PATH%.