aboutsummaryrefslogtreecommitdiffstats
path: root/src/webview/spellchecker.js
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-08-21 08:07:32 +0530
committerLibravatar Vijay A <avijayr@protonmail.com>2021-08-21 08:55:38 +0530
commitb1cf1849f5bfa8f297f78a5ca58d797f466b3086 (patch)
tree658f3adeb740cf54021dfb6ad951649f0d539e6d /src/webview/spellchecker.js
parentrefactor(cleanup): remove code that refers to paid subscription (diff)
downloadferdium-app-b1cf1849f5bfa8f297f78a5ca58d797f466b3086.tar.gz
ferdium-app-b1cf1849f5bfa8f297f78a5ca58d797f466b3086.tar.zst
ferdium-app-b1cf1849f5bfa8f297f78a5ca58d797f466b3086.zip
chore: typescript conversion
Diffstat (limited to 'src/webview/spellchecker.js')
-rw-r--r--src/webview/spellchecker.js39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/webview/spellchecker.js b/src/webview/spellchecker.js
deleted file mode 100644
index 0f4715207..000000000
--- a/src/webview/spellchecker.js
+++ /dev/null
@@ -1,39 +0,0 @@
1import { getCurrentWebContents } from '@electron/remote';
2import { SPELLCHECKER_LOCALES } from '../i18n/languages';
3import { DEFAULT_APP_SETTINGS, isMac } from '../environment';
4
5const debug = require('debug')('Ferdi:spellchecker');
6
7const webContents = getCurrentWebContents();
8const [defaultLocale] = webContents.session.getSpellCheckerLanguages();
9debug('Spellchecker default locale is', defaultLocale);
10
11export function getSpellcheckerLocaleByFuzzyIdentifier(identifier) {
12 const locales = Object.keys(SPELLCHECKER_LOCALES).filter((key) => key.toLocaleLowerCase() === identifier.toLowerCase() || key.split('-')[0] === identifier.toLowerCase());
13
14 if (locales.length >= 1) {
15 return locales[0];
16 }
17
18 return null;
19}
20
21export function switchDict(locale) {
22 if (isMac) {
23 debug('Ignoring dictionary changes on macOS');
24 return;
25 }
26
27 debug('Setting spellchecker locale to', locale);
28
29 const locales = [];
30 const foundLocale = getSpellcheckerLocaleByFuzzyIdentifier(locale);
31
32 if (foundLocale) {
33 locales.push(foundLocale);
34 }
35
36 locales.push(defaultLocale, DEFAULT_APP_SETTINGS.fallbackLocale);
37
38 webContents.session.setSpellCheckerLanguages(locales);
39}