1 import { Language, MyUserInfo } from "lemmy-js-client";
2 import { I18NextService } from "../../services/I18NextService";
4 export default function getUserInterfaceLanguageId({
8 myUserInfo: MyUserInfo;
9 allLanguages: Language[];
11 // Get the string of the browser- or user-defined language, like en-US
12 const i18nLang = I18NextService.i18n.language;
14 // Find the Language object with a code that matches the initial characters of
16 const userLang = allLanguages.find(lang => {
17 return i18nLang.indexOf(lang.code) === 0;
20 // Return the ID of that language object, or "0" for Undetermined
21 return userLang.id || 0;