Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+7
-8
@@ -1,5 +1,5 @@
|
||||
import { defaultLocale, isSupportedLocale } from "@hivegrid/i18n";
|
||||
import { remixI18Next } from "./i18next.server";
|
||||
import { defaultLocale, normalizeLocaleCandidate, type SupportedLocale } from "@hivegrid/i18n";
|
||||
import { enabledLocales, remixI18Next } from "./i18next.server";
|
||||
|
||||
/**
|
||||
* Mail-side translator function. Kept locally now that the legacy
|
||||
@@ -16,10 +16,9 @@ const MAIL_NAMESPACE = "mail" as const;
|
||||
* Normalize a (possibly null/unsupported) locale string to a supported locale,
|
||||
* falling back to {@link defaultLocale} when no supported match is found.
|
||||
*/
|
||||
export function resolveMailLocale(locale: string | null | undefined): string {
|
||||
if (locale && isSupportedLocale(locale)) {
|
||||
return locale;
|
||||
}
|
||||
export function resolveMailLocale(locale: string | null | undefined): SupportedLocale {
|
||||
const normalized = normalizeLocaleCandidate(locale);
|
||||
if (normalized && enabledLocales.includes(normalized)) return normalized;
|
||||
return defaultLocale;
|
||||
}
|
||||
|
||||
@@ -29,7 +28,7 @@ export function resolveMailLocale(locale: string | null | undefined): string {
|
||||
*/
|
||||
export async function getMailTranslator(locale: string | null | undefined): Promise<{
|
||||
t: MailTranslator;
|
||||
locale: string;
|
||||
locale: SupportedLocale;
|
||||
}> {
|
||||
const resolved = resolveMailLocale(locale);
|
||||
const fixedT = await remixI18Next.getFixedT(resolved, MAIL_NAMESPACE);
|
||||
@@ -44,7 +43,7 @@ export async function getMailTranslator(locale: string | null | undefined): Prom
|
||||
*/
|
||||
export async function getMailTranslatorFromRequest(request: Request): Promise<{
|
||||
t: MailTranslator;
|
||||
locale: string;
|
||||
locale: SupportedLocale;
|
||||
}> {
|
||||
const detected = await remixI18Next.getLocale(request);
|
||||
return getMailTranslator(detected);
|
||||
|
||||
Reference in new issue
Block a user