Revert "Unify workspace dropdowns; Update layouts (#458)"

This reverts commit 4bc8448a1d.
This commit is contained in:
gbuomprisco
2026-03-11 14:47:47 +08:00
parent 4bc8448a1d
commit 4912e402a3
530 changed files with 11182 additions and 14382 deletions

View File

@@ -1,47 +1,32 @@
import type { AbstractIntlMessages } from 'next-intl';
import { createTranslator } from 'next-intl';
import { createI18nSettings } from '@kit/i18n';
import { initializeServerI18n } from '@kit/i18n/server';
export async function initializeEmailI18n(params: {
export function initializeEmailI18n(params: {
language: string | undefined;
namespace: string;
}) {
const language = params.language ?? 'en';
const language =
params.language ?? process.env.NEXT_PUBLIC_DEFAULT_LOCALE ?? 'en';
try {
// Load the translation messages for the specified namespace
const messages = (await import(
`../locales/${language}/${params.namespace}.json`
)) as AbstractIntlMessages;
// Create a translator function with the messages
const translator = createTranslator({
locale: language,
messages,
});
// Type-cast to make it compatible with the i18next API
const t = translator as unknown as (
key: string,
values?: Record<string, unknown>,
) => string;
// Return an object compatible with the i18next API
return {
t,
return initializeServerI18n(
createI18nSettings({
language,
};
} catch (error) {
console.log(
`Error loading i18n file: locales/${language}/${params.namespace}.json`,
error,
);
languages: [language],
namespaces: params.namespace,
}),
async (language, namespace) => {
try {
const data = await import(`../locales/${language}/${namespace}.json`);
// Return a fallback translator that returns the key as-is
const t = (key: string) => key;
return data as Record<string, string>;
} catch (error) {
console.log(
`Error loading i18n file: locales/${language}/${namespace}.json`,
error,
);
return {
t,
language,
};
}
return {};
}
},
);
}