import { For, createMemo } from "solid-js"; import { Trans, useLingui } from "@lingui-solid/solid/macro"; import { Language, Languages, browserPreferredLanguage } from "@revolt/i18n"; import type { LanguageEntry } from "@revolt/i18n/Languages"; import { timeLocale } from "@revolt/i18n/dayjs"; import { UnicodeEmoji } from "@revolt/markdown/emoji"; import { useState } from "@revolt/state"; import { CategoryButton, CategoryButtonGroup, CategoryCollapse, Checkbox, Column, Row, Time, iconSize, } from "@revolt/ui"; import MdErrorFill from "@material-design-icons/svg/filled/error.svg?component-solid"; import MdVerifiedFill from "@material-design-icons/svg/filled/verified.svg?component-solid"; import MdCalendarMonth from "@material-design-icons/svg/outlined/calendar_month.svg?component-solid"; import MdLanguage from "@material-design-icons/svg/outlined/language.svg?component-solid"; import MdSchedule from "@material-design-icons/svg/outlined/schedule.svg?component-solid"; import MdTranslate from "@material-design-icons/svg/outlined/translate.svg?component-solid"; /** * Language */ export function LanguageSettings() { return ( {/* */} ); } /** * Pick user's preferred language */ function PickLanguage() { const state = useState(); const { i18n } = useLingui(); /** * Determine the current language */ const currentLanguage = () => Languages[i18n().locale as never] as LanguageEntry; // Generate languages array. const languages = createMemo(() => { const languages = Object.keys(Languages).map( (x) => [x, Languages[x as keyof typeof Languages]] as const, ); const preferredLanguage = browserPreferredLanguage(); if (preferredLanguage) { // This moves the user's system language to the top of the language list const prefLangKey = languages.find( (lang) => lang[0].replace(/_/g, "-") == preferredLanguage, ); if (prefLangKey) { languages.splice( 0, 0, languages.splice(languages.indexOf(prefLangKey), 1)[0], ); } } return languages; }); return ( } title={Select your language} description={currentLanguage().display} scrollable > {([id, lang]) => ( } action={} onClick={() => state.locale.switch(id as Language)} > {lang.display}{" "} {lang.verified && ( )}{" "} {lang.incomplete && ( )} )} ); } /** * Pick user's preferred date format */ function PickDateFormat() { const state = useState(); const { t } = useLingui(); const date = () => timeLocale()[1].formats.L; const LastWeek = new Date(); LastWeek.setDate(LastWeek.getDate() - 7); return ( } title="Select date format" description={ date() === "DD/MM/YYYY" ? t`Traditional (DD/MM/YYYY)` : date() === "MM/DD/YYYY" ? t`American (MM/DD/YYYY)` : date() === "YYYY-MM-DD" ? t`ISO Standard (YYYY-MM-DD)` : date() } > state.locale.setDateFormat("DD/MM/YYYY")} action={} description={ state.locale.setDateFormat("MM/DD/YYYY")} action={} description={ state.locale.setDateFormat("YYYY-MM-DD")} action={} description={ ); } /** * Pick user's preferred time format */ function PickTimeFormat() { const state = useState(); const { t } = useLingui(); const time = () => timeLocale()[1].formats.LT; return ( } title="Select time format" description={time() === "HH:mm" ? t`24 hours` : t`12 hours`} > state.locale.setTimeFormat("HH:mm")} action={} description={ state.locale.setTimeFormat("h:mm A")} action={} description={ ); } // /** // * Configure right-to-left display // */ // function ConfigureRTL() { // /** // * Determine the current language // */ // const currentLanguage = () => Languages[language()]; // return ( // } // description={Flip the user interface right to left} // action={} // onClick={() => void 0} // > // Enable RTL layout // // } // > // // } // description={Keep the user interface left to right} // action={} // onClick={() => void 0} // > // Force LTR layout // // // // ); // } /** * Language contribution link */ function ContributeLanguageLink() { return ( } onClick={() => void 0} description={ Help contribute to an existing or new language } > Contribute a language ); }