diff options
author | Vijay A <avijayr@protonmail.com> | 2021-08-21 08:07:32 +0530 |
---|---|---|
committer | Vijay A <avijayr@protonmail.com> | 2021-08-21 08:55:38 +0530 |
commit | b1cf1849f5bfa8f297f78a5ca58d797f466b3086 (patch) | |
tree | 658f3adeb740cf54021dfb6ad951649f0d539e6d /src/webview/spellchecker.js | |
parent | refactor(cleanup): remove code that refers to paid subscription (diff) | |
download | ferdium-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.js | 39 |
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 @@ | |||
1 | import { getCurrentWebContents } from '@electron/remote'; | ||
2 | import { SPELLCHECKER_LOCALES } from '../i18n/languages'; | ||
3 | import { DEFAULT_APP_SETTINGS, isMac } from '../environment'; | ||
4 | |||
5 | const debug = require('debug')('Ferdi:spellchecker'); | ||
6 | |||
7 | const webContents = getCurrentWebContents(); | ||
8 | const [defaultLocale] = webContents.session.getSpellCheckerLanguages(); | ||
9 | debug('Spellchecker default locale is', defaultLocale); | ||
10 | |||
11 | export 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 | |||
21 | export 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 | } | ||