This commit is contained in:
giancarlo
2024-03-24 02:23:22 +08:00
parent 648d77b430
commit bce3479368
589 changed files with 37067 additions and 9596 deletions

View File

@@ -0,0 +1,45 @@
import { InitOptions } from 'i18next';
const fallbackLng = 'en';
const languages: string[] = [fallbackLng];
export const I18N_COOKIE_NAME = 'lang';
/**
* The default array of Internationalization (i18n) namespaces.
* These namespaces are commonly used in the application for translation purposes.
*
* Add your own namespaces here
**/
export const defaultI18nNamespaces = [
'common',
'auth',
'organization',
'profile',
'subscription',
'onboarding',
];
export function getI18nSettings(
language: string | undefined,
ns: string | string[] = defaultI18nNamespaces,
): InitOptions {
let lng = language ?? fallbackLng;
if (!languages.includes(lng)) {
console.warn(
`Language "${lng}" is not supported. Falling back to "${fallbackLng}"`,
);
lng = fallbackLng;
}
return {
supportedLngs: languages,
fallbackLng,
lng,
fallbackNS: defaultI18nNamespaces,
defaultNS: defaultI18nNamespaces,
ns,
};
}