Files
outline/app/utils/language.ts
Tom Moor cc333637dd Desktop support (#4484)
* Remove home link on desktop app

* Spellcheck, installation toasts, background styling, …

* Add email,slack, auth support

* More desktop style tweaks

* Move redirect to client

* cleanup

* Record desktop usage

* docs

* fix: Selection state in search input when double clicking header
2022-11-27 15:07:48 -08:00

23 lines
678 B
TypeScript

import { i18n } from "i18next";
import Desktop from "./Desktop";
export function detectLanguage() {
const [ln, r] = navigator.language.split("-");
const region = (r || ln).toUpperCase();
return `${ln}_${region}`;
}
export function changeLanguage(
toLanguageString: string | null | undefined,
i18n: i18n
) {
if (toLanguageString && i18n.language !== toLanguageString) {
// Languages are stored in en_US format in the database, however the
// frontend translation framework (i18next) expects en-US
const locale = toLanguageString.replace("_", "-");
i18n.changeLanguage(locale);
Desktop.bridge?.setSpellCheckerLanguages(["en-US", locale]);
}
}