i18n: add createTranslator
This commit is contained in:
parent
8a9c788fe1
commit
4ae3def190
2 changed files with 11 additions and 7 deletions
|
@ -27,33 +27,32 @@ import { Title } from "../material/typography.jsx";
|
|||
import { css } from "solid-styled";
|
||||
import { useSignedInProfiles } from "../masto/acct.js";
|
||||
import { signOut, type Account } from "../accounts/stores.js";
|
||||
import { format, intlFormat } from "date-fns";
|
||||
import { format } from "date-fns";
|
||||
import { useStore } from "@nanostores/solid";
|
||||
import { $settings } from "./stores.js";
|
||||
import { useRegisterSW } from "virtual:pwa-register/solid";
|
||||
import {
|
||||
autoMatchLangTag,
|
||||
autoMatchRegion,
|
||||
createStringResource,
|
||||
createTranslator,
|
||||
SUPPORTED_LANGS,
|
||||
SUPPORTED_REGIONS,
|
||||
useDateFnLocale,
|
||||
} from "../platform/i18n.jsx";
|
||||
import { resolveTemplate, translator, type Template } from "@solid-primitives/i18n";
|
||||
import { type Template } from "@solid-primitives/i18n";
|
||||
|
||||
type Strings = {
|
||||
["lang.auto"]: Template<{detected: string}>
|
||||
} & Record<string, string | undefined>
|
||||
|
||||
const Settings: ParentComponent = () => {
|
||||
const [strings] = createStringResource(
|
||||
const [t] = createTranslator(
|
||||
(code) =>
|
||||
import(`./i18n/${code}.json`) as Promise<{
|
||||
default: Strings;
|
||||
}>,
|
||||
() => import(`./i18n/lang-names.json`)
|
||||
);
|
||||
const t = translator(strings, resolveTemplate);
|
||||
const navigate = useNavigate();
|
||||
const settings$ = useStore($settings);
|
||||
const {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue