Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Enable overwriting dictionary base url #120

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions lib/spellchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var bindings = require('../build/Release/spellchecker.node');
var Spellchecker = bindings.Spellchecker;

var defaultSpellcheck = null;
var dictionaryBaseURL = "https://redirector.gvt1.com/edgedl/chrome/dict/";

var ensureDefaultSpellCheck = function() {
if (defaultSpellcheck) {
Expand Down Expand Up @@ -74,16 +75,22 @@ var getDictionaryPath = function() {
return dict;
}

var setBaseUrlForHunspellDictionary = function(url) {
if(url && url.length > 0){
dictionaryBaseURL = url
}
}

var getURLForHunspellDictionary = function(lang) {
// NB: This is derived from https://code.google.com/p/chromium/codesearch#chromium/src/chrome/common/spellcheck_common.cc&sq=package:chromium&type=cs&rcl=1464736770&l=107
var defaultVersion = '-3-0';
var specialVersions = {
'tr-tr': '-4-0',
'tg-tg': '-5-0',
'en-ca': '-7-1',
'en-gb': '-7-1',
'en-us': '-7-1',
'fa-ir': '-7-0',
'en-ca': '-8-0',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why were these numbers changed? The link above seams to be dead.

'en-gb': '-8-0',
'en-us': '-8-0',
'fa-ir': '-8-0',
};

var nonFormedLangCode = ['ko', 'sh', 'sq', 'sr'];
Expand All @@ -98,7 +105,7 @@ var getURLForHunspellDictionary = function(lang) {
}
}

return "https://redirector.gvt1.com/edgedl/chrome/dict/" + langCode + (specialVersions[langCode] || defaultVersion) + ".bdic";
return dictionaryBaseURL + langCode + (specialVersions[langCode] || defaultVersion) + ".bdic";
}

module.exports = {
Expand All @@ -110,5 +117,6 @@ module.exports = {
getAvailableDictionaries: getAvailableDictionaries,
getCorrectionsForMisspelling: getCorrectionsForMisspelling,
getURLForHunspellDictionary: getURLForHunspellDictionary,
setBaseUrlForHunspellDictionary: setBaseUrlForHunspellDictionary,
Spellchecker: Spellchecker
};
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"main": "./lib/spellchecker.js",
"name": "spellchecker",
"name": "node-spellcheckr",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misspelt.

"description": "Bindings to native spellchecker",
"version": "4.0.0",
"version": "4.0.1",
"licenses": [
{
"type": "MIT",
Expand Down