Skip to content

Instantly share code, notes, and snippets.

@lalau
lalau / i18nextLanguageJson.ts
Created February 16, 2022 09:59 — forked from SimeonC/i18nextLanguageJson.ts
Using Webpack code-split "backend" for i18next translations. Note that your withTranslations/useTranslations must use namespaces or include a default namespace or the read function doesn't get called
// Used for one JSON file for each language containing all namespaces
i18next.use({
type: 'backend',
read<Namespace extends keyof typeof en>(
language: LocaleCode,
namespace: Namespace,
callback: (
errorValue: unknown,
translations: null | typeof en[Namespace]
) => void