Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Changes from all 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
19 changes: 15 additions & 4 deletions lib/spellchecker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ var ensureDefaultSpellCheck = function() {

var setDictionary = function(lang, dictPath) {
ensureDefaultSpellCheck();

var filePath = path.join(dictPath, lang.replace(/_/g, '-') + '.bdic');
var contents = null;

try {
contents = fs.readFileSync(filePath);
} catch (e) {
return false;
}

return defaultSpellcheck.setDictionary(lang, contents);
};

Expand Down Expand Up @@ -85,8 +85,19 @@ var getURLForHunspellDictionary = function(lang) {
'en-us': '-7-1',
'fa-ir': '-7-0',
};


var nonFormedLangCode = ['ko', 'sh', 'sq', 'sr'];
var langCode = lang.replace(/_/g, '-').toLowerCase();

//some bdict in choromium does not follow form of language code with locale,
//formed as language only (i.e, https://src.chromium.org/viewvc/chrome/trunk/deps/third_party/hunspell_dictionaries/ko-3-0.bdic)
var language = langCode.split('-')[0];
for (var idx = 0; idx < nonFormedLangCode.length; idx++) {
if (language === nonFormedLangCode[idx]) {
langCode = nonFormedLangCode[idx];
}
}

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

Expand Down