make spellcheck use all system locales
This commit is contained in:
parent
9120d05efc
commit
70dd38f79d
4 changed files with 17 additions and 2 deletions
|
@ -4,7 +4,7 @@
|
||||||
* Copyright (c) 2023 Vendicated and Vencord contributors
|
* Copyright (c) 2023 Vendicated and Vencord contributors
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { app, dialog, ipcMain, shell } from "electron";
|
import { app, dialog, ipcMain, session, shell } from "electron";
|
||||||
import { existsSync, readFileSync, watch } from "fs";
|
import { existsSync, readFileSync, watch } from "fs";
|
||||||
import { open, readFile } from "fs/promises";
|
import { open, readFile } from "fs/promises";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
|
@ -60,6 +60,14 @@ ipcMain.handle(IpcEvents.CLOSE, e => {
|
||||||
e.sender.close();
|
e.sender.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ipcMain.handle(IpcEvents.SPELLCHECK_SET_LANGUAGES, (_, languages: string[]) => {
|
||||||
|
const ses = session.defaultSession;
|
||||||
|
|
||||||
|
const available = ses.availableSpellCheckerLanguages;
|
||||||
|
const applicable = languages.filter(l => available.includes(l)).slice(0, 3);
|
||||||
|
if (applicable.length) ses.setSpellCheckerLanguages(applicable);
|
||||||
|
});
|
||||||
|
|
||||||
ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
ipcMain.handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
|
||||||
const res = await dialog.showOpenDialog(mainWin!, {
|
const res = await dialog.showOpenDialog(mainWin!, {
|
||||||
properties: ["openDirectory"]
|
properties: ["openDirectory"]
|
||||||
|
|
|
@ -23,6 +23,10 @@ export const VencordDesktopNative = {
|
||||||
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
get: () => sendSync<Settings>(IpcEvents.GET_SETTINGS),
|
||||||
set: (settings: Settings, path?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, path)
|
set: (settings: Settings, path?: string) => invoke<void>(IpcEvents.SET_SETTINGS, settings, path)
|
||||||
},
|
},
|
||||||
|
spellcheck: {
|
||||||
|
setLanguages: (languages: readonly string[]) => invoke<void>(IpcEvents.SPELLCHECK_SET_LANGUAGES, languages)
|
||||||
|
// todo: perhaps add ways to learn words
|
||||||
|
},
|
||||||
win: {
|
win: {
|
||||||
focus: () => invoke<void>(IpcEvents.FOCUS)
|
focus: () => invoke<void>(IpcEvents.FOCUS)
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,5 +39,6 @@ if (IS_DEV) {
|
||||||
document.getElementById("vcd-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
|
document.getElementById("vcd-css-core")!.textContent = readFileSync(rendererCss, "utf-8");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
VencordDesktopNative.spellcheck.setLanguages(window.navigator.languages);
|
||||||
|
|
|
@ -25,5 +25,7 @@ export const enum IpcEvents {
|
||||||
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
|
UPDATER_DOWNLOAD = "VCD_UPDATER_DOWNLOAD",
|
||||||
UPDATE_IGNORE = "VCD_UPDATE_IGNORE",
|
UPDATE_IGNORE = "VCD_UPDATE_IGNORE",
|
||||||
|
|
||||||
|
SPELLCHECK_SET_LANGUAGES = "VCD_SPELLCHECK_SET_LANGUAGES",
|
||||||
|
|
||||||
CLOSE = "VCD_CLOSE"
|
CLOSE = "VCD_CLOSE"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue