skinny-azureS
Refine3y ago
8 replies
skinny-azure

using the react-i18next example I guess a type mismatch

Hey everyone, I just started integrating translations into our application and noticed that the documentation is a little bit off. Here (https://refine.dev/docs/api-reference/core/providers/i18n-provider/#creating-the-i18n-provider) in the docs it says that we should do the following:

const { t, i18n } = useTranslation();

const i18nProvider: I18nProvider = {
  translate: (key: string, options?: any) => t(key, options),
  changeLocale: (lang: string) => i18n.changeLanguage(lang),
  getLocale: () => i18n.language,
};


But this leads to a type mismatch between the I18nProdiver (from @refinedev/core) and the t function from react-i18next:
TS2322: Type '(key: string, options?: any) => string | TFunctionDetailedResult<string>' is not assignable to type 'Translate'.
        Type 'string | TFunctionDetailedResult<string>' is not assignable to type 'string'.
        Type 'TFunctionDetailedResult<string>' is not assignable to type 'string'.


I guess I'm not the only one getting that error. Maybe there is a common work-around already?
Was this page helpful?