mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-12-11 06:57:13 +08:00
Fix error on Windows for chinese users: "zh-CN" is not valid unless language pack installed
This commit is contained in:
parent
738fb2ec02
commit
6b5a74f718
1 changed files with 9 additions and 10 deletions
|
|
@ -7,7 +7,6 @@ const { app, MenuItem } = require('@electron/remote');
|
|||
const customDictFilePath = path.join(AppEnv.getConfigDirPath(), 'custom-dict.json');
|
||||
|
||||
class Spellchecker {
|
||||
|
||||
private _session = require('@electron/remote').getCurrentWebContents().session;
|
||||
|
||||
constructor() {
|
||||
|
|
@ -33,15 +32,18 @@ class Spellchecker {
|
|||
} else {
|
||||
setTimeout(initHandler, 5000);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_switchToLanguage = (lang: string | undefined | null) => {
|
||||
if (lang === null || lang === undefined || lang === '') {
|
||||
lang = app.getLocale() || 'en-US';
|
||||
}
|
||||
|
||||
this._session.setSpellCheckerLanguages([lang]);
|
||||
const supported: string[] = this._session.availableSpellCheckerLanguages || [];
|
||||
if (supported.includes(lang)) {
|
||||
this._session.setSpellCheckerLanguages([lang]);
|
||||
} else if (lang.includes('-') && supported.includes(lang.split('-')[0])) {
|
||||
this._session.setSpellCheckerLanguages([lang.split('-')[0]]);
|
||||
}
|
||||
};
|
||||
|
||||
_migrateFromCustomDict = () => {
|
||||
|
|
@ -58,13 +60,12 @@ class Spellchecker {
|
|||
}
|
||||
const loadedDict = JSON.parse(fileData);
|
||||
Object.keys(loadedDict).forEach(word => this._session.addWordToSpellCheckerDictionary(word));
|
||||
fs.unlink(customDictFilePath, () => { });
|
||||
fs.unlink(customDictFilePath, () => {});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
isMisspelled = (word: string) => {
|
||||
return webFrame.isWordMisspelled(word)
|
||||
return webFrame.isWordMisspelled(word);
|
||||
};
|
||||
|
||||
learnWord = (word: string) => {
|
||||
|
|
@ -77,7 +78,6 @@ class Spellchecker {
|
|||
};
|
||||
|
||||
appendSpellingItemsToMenu = async ({ menu, word, onCorrect, onDidLearn }) => {
|
||||
|
||||
if (this.isMisspelled(word)) {
|
||||
const corrections = webFrame.getWordSuggestions(word);
|
||||
if (corrections.length > 0) {
|
||||
|
|
@ -108,7 +108,6 @@ class Spellchecker {
|
|||
menu.append(new MenuItem({ type: 'separator' }));
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
export default new Spellchecker();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue