Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for French language (contribution offer) #31

Closed
adrienjoly opened this issue Jan 11, 2017 · 17 comments
Closed

Add support for French language (contribution offer) #31

adrienjoly opened this issue Jan 11, 2017 · 17 comments

Comments

@adrienjoly
Copy link

Hi!

I love vscode, but keep using SublimeText just because it has an offline spellcheck extension for the French language: https://github.com/superbob/SublimeTextLanguageFrench

Being a developer myself, I would be happy to contribute to your project (or start a new one, if you think that it makes more sense), so that I can run offline spellchecking for my French documents from vscode.

Do you have any suggestions to provide, on how I/we could do that?

@swyphcosmo
Copy link
Owner

Adding more languages is something that I've had on my list for a while, but I haven't made the time for it.

All it takes to add a new language is to add a Hunspell compatible dictionary (.dic and .aff files) to the /languages directory in this repo.

One drawback of this is that the language files are pretty big (relative to the rest of the files in the extension). A person will have every language installed independent of which ones they use. I've been thinking about adding the ability to download the language selectively based on what is used. There's a great repository of dictionary files maintained by wooorm https://github.com/wooorm/dictionaries. He also has a lot of packages that I've been looking to integrate to increase the functionality of this extension.

It might be a while before I get around to adding this functionality, so feel free to submit a PR in the mean time

@adrienjoly
Copy link
Author

adrienjoly commented Jan 18, 2017

Hi @swyphcosmo!

Thanks for your reply!

I tried that (you can watch me do it), but ended up having a blocking error after adding FR dictionary files...

Here's a journal of what I did:

Add a French spellchecker to Visual Studio Code

Steps:

  • Install and test existing extension: vscode-spellchecker
  • Fork vscode-spellchecker and make it work locally
  • Integrate a French dictionary (Hunspell .dic/.aff files)
  • Package the fork as an extension
  • Pull Request vscode-spellchecker
  • Don't need to use SublimeText anymore to edit my markdown files! \o/

Journal:

  • problem: the extension was not working
  • found a working alternative: working OK, but using an online API / web service => can't use offline...
  • switched back to the initial extension, found out that my problem was caused by a syntax error in my JSON vscode configuration file... => fixed it
  • forked the extension's repo to https://github.com/adrienjoly/vscode-spellchecker, then cloned it locally
  • moved the local repo to vscode's extensions directory, as explained here
  • found out that the extension's directory name had to match the extension's name (=> removed the -fr suffix)
  • also found out that I needed to run npm i (to install dependencies), then npm run vscode:prepublish (to compile the extension's source code) to make the extension show up in vscode's extensions list
  • tried changing the extension's title from package.json => had to restart vscode to see the change in vscode's extensions list
  • test: the local version of the extension works √
  • found a french dictionary there
  • realised that using npm to install it was not a solution, because the extension loads dictionaries from a specifically-defined directory only => moved FR dictionary files in that directory, and renamed them to match others.
  • test: set "fr_FR" as language in the .vscode/spellchecker.json file of my sample workspace (directory) => the spell check did not work, found errors in vscode's console:
//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:127 [Extension Host] Activating extension `swyphcosmo.spellchecker` failed: {1}.A.logExtensionHostMessage @ //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:127
//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:127 [Extension Host] Activating extension `swyphcosmo.spellchecker` failed:  undefinedA.logExtensionHostMessage @ //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:127
//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:127 [Extension Host] Here is the error stack:  undefined
//Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:109 Activating extension `swyphcosmo.spellchecker` failed: {1}.t.$localShowMessage @ //Applications/Visual Studio Code.app/Contents/Resources/app/out/vs/workbench/electron-browser/workbench.main.js:109
  • tried removing FR dictionaries and reverting my workspace settings, but the same error was happening every time I restarted vscode... => I quit from there

@swyphcosmo
Copy link
Owner

You don't want to add the local repo to the vscode's extension directory. Because you're testing new functionality, you want to debug the extension from within VSCode.

  • clone the repository
  • run npm install to install all the typescript dependencies
  • open the repository in VSCode
  • press 'F5' to debug the extension

At this point, a new editor window will open with the local spellchecker extension enabled.

I'm not sure what those errors are. They could have something to do with how the extension was installed. Here's how you can get more detailed information.

  • Open /src/features/SpellCheckerProvider.ts
  • On Line 11, change false to true to enable debug output.

If you send me the log from the Developer Tools console, I can try to help out more.

@adrienjoly
Copy link
Author

@swyphcosmo I did not know about all that, thank for having taken the time to explain!

I will probably plan another live coding session to do this, next week! I'll let you know!

@adrienjoly
Copy link
Author

adrienjoly commented Jan 25, 2017

Add a French spellchecker to Visual Studio Code (2nd try)

Live coding simultaneously from:

Steps:

  • Install and test existing extension: vscode-spellchecker
  • Clone my fork and test it locally (using F5)
  • Integrate a French dictionary (Hunspell .dic/.aff files) and test
  • Pull Request vscode-spellchecker

@adrienjoly
Copy link
Author

adrienjoly commented Jan 25, 2017

@swyphcosmo Some progress and a PR, thanks to your advice!

Unfortunately, the French spell-checker is failing on some words:

screen shot 2017-01-25 at 14 53 27

Also, I wasted a lot of time figuring out that I needed to install a git submodule for hunspell-spellcheck, so I took the liberty to add a preinstall hook to do that automatically in package.json.

Video of me doing this: Make a FR spellchecker for Visual Studio Code (Youtube)

@adrienjoly
Copy link
Author

@swyphcosmo Switching from the Hunspell submodule to Atom's node-spellcheck npm module solved my French spelling problems, and runs much faster.

One drawback is that the extension needs to be compiled separately for each platform, because Atom's node-spellcheck npm module is a native module. And I had to use electron-rebuild in order to compile accordingly to VSCode's Electron version.

@adrienjoly
Copy link
Author

@swyphcosmo I took the liberty to publish my fork of your extension on the marketplace: under the name French spell checker. (the corresponding forked repo is there)

I only tested it on Mac OS, and I doubt that it works on other platforms. I'm happy to collaborate if anybody wants to try it on another platform.

@swyphcosmo
Copy link
Owner

Just added dictionaries. Will be pushing a new release soon.

@adrienjoly
Copy link
Author

awesome!

make sure that "j'aime" is not spotted as a spelling error. this is the reason why I had forked this extension.

@swyphcosmo
Copy link
Owner

Thanks for the suggestion. I was looking at the samples you provided, but wasn't sure which word should be spelled correctly. I know that one still caused an error, so I'll look into it.

@ghost
Copy link

ghost commented Mar 8, 2018

I did try on Debian GNU/Linux.
@adrienjoly mentioned he has only tested on MacosX so far.

and guess what?
not working... as expected.

I would like to help.
anybody may suggest clues to try out...

@swyphcosmo
Copy link
Owner

@pvincent. I haven't used @adrienjoly's fork of this extension as I'm not a French speaker. He's using a third party npm package called spellchecker which supports native spell checker software. It should work on Linux, but you might need to install the native spellchecker through apt. I would suggest looking into that npm package or opening an issue on @adrienjoly's fork for help debugging your problem.

@ghost
Copy link

ghost commented Mar 9, 2018 via email

@adrienjoly
Copy link
Author

Hi @pvincent! I'd be interested to know what extension you've ended up using, and how well it's working for you, if you don't mind :-)

@ghost
Copy link

ghost commented Mar 11, 2018 via email

@adrienjoly
Copy link
Author

I will check them out! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants