B2B-88: add starter kit structure and elements
This commit is contained in:
41
packages/i18n/src/create-i18n-settings.ts
Normal file
41
packages/i18n/src/create-i18n-settings.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import type { InitOptions } from 'i18next';
|
||||
|
||||
/**
|
||||
* Get i18n settings for i18next.
|
||||
* @param languages
|
||||
* @param language
|
||||
* @param namespaces
|
||||
*/
|
||||
export function createI18nSettings({
|
||||
languages,
|
||||
language,
|
||||
namespaces,
|
||||
}: {
|
||||
languages: string[];
|
||||
language: string;
|
||||
namespaces?: string | string[];
|
||||
}): InitOptions {
|
||||
const lng = language;
|
||||
const ns = namespaces;
|
||||
|
||||
return {
|
||||
supportedLngs: languages,
|
||||
fallbackLng: languages[0],
|
||||
detection: undefined,
|
||||
lng,
|
||||
preload: false as const,
|
||||
lowerCaseLng: true as const,
|
||||
fallbackNS: ns,
|
||||
missingInterpolationHandler: (text, value, options) => {
|
||||
console.debug(
|
||||
`Missing interpolation value for key: ${text}`,
|
||||
value,
|
||||
options,
|
||||
);
|
||||
},
|
||||
ns,
|
||||
react: {
|
||||
useSuspense: true,
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user