You'll have to rely on some external tool. So either build a wrapper that support multi-language or use an existing one that may not support multi language.
I think the main problem around multi-language syntax and grammar (
iabbrev S/G syntax and grammar) correcting is that you always have to rely on some external tools that may not work for all languages. I'm thinking about afterthedeadline that has a convenient vim plugin but (from what I found) only correct english. So if you want only english, you can settle with this one but, as you specified, you want to correct french too (and maybe one day spanish or german, ... ). So a common multi-language S/G checker should achieve this.
We're on internet ! So you can find anything that can help you. And there are a LOT of S/G you can use freely. e.g.:
And one in particular: reverso.
I first used this website because as a non-english native I did a lot of translation from this site (where the quality of translation impressed me). And I just found out that they also so a syntax checker for English and French. So basically what you are searching for.
To use this from Vim I wanted to have a curl-only interface with the website, so I started analysing the request to narrow my search to :
curl -X "POST" "http://www.reverso.net/spell-checker/french-spelling-grammar/SpellerRequests.aspx" \
--data-urlencode "language=fr" \
--data-urlencode "interfLang=en" \
--data-urlencode "passPhrase=a long passphrase" \
--data-urlencode "dictionary=both" \
--data-urlencode "lang=en " \
--data-urlencode "inputstring=Bnjour tout le monde"
And the result was:
<sentence id="0" start="0" length="20" language="Fr">
<inputText> Bnjour tout le monde</inputText>
<error id="0" type="spell" substitution="" start="0" end="6" proba="100">
<message> #!Bnjour#$ : mot inconnu de nos dictionnaires, il pourrait être remplacé par: #!Bonjour#$,#! BN jour#$.</message>
<alternative id="0"> Bnjour</alternative>
<alternative id="1"> Bonjour</alternative>
<alternative id="2"> BN jour</alternative>
<textreplaced> Bnjour tout le monde</textreplaced>
From this result you can parse the XML string and get the informations you want, building it in the quick fix list or trying to inject it in a plugin (syntastic for example).
Side Note :
For this solution, you'll have to ask for the website 2 times : one for fetching the passphrase and the second for correcting your text. It's kind of hacky but it'll work.
(spoiler alert : no script, just a general conclusion)
I think most of the tool you can use to check you grammar/syntax will work the same as reverso. The only thing that change will be the output that you'll have to parse each time. And having to handle all the cases can be a really consuming task when some tools already exists that works out-of-the-box.
I think you can write some script that will do one of the following :
- Prepare the texte to be verified in an external tool (Microsoft Word, Google Doc, ... ) and re-inserted inside Vim afterward. Easy
- Try to use an external tool directly from Vim with the requests and the parsing, ... Hard
But eventually you'll learn a lot on choosing the hard solution.
While trying to verify this text from reverso, I saw that the text should have a size of 600 characters max ... And I think this can be found on other online-free-to-use tools like this one.