How to pass Internationalization.json to jsonform component using i18n in react?

Hi @SouradeepMldt,

What you need to do is to integrate the content of the i18n.json file you posted into your translator. So depending on your environment you can import your i18n.json file or request it from some backend. Then you create the translator and access the object within it, e.g. via lodash’s get.

For example like this (note that I wrote this from the top of my head and it’s untested).

import myi18nfile from './i18n.json'; // your tool chain must be able to handle json imports
import get from 'lodash/get';

const createTranslator = locale => (key, defaultMessage) => {
  return get(myi18nfile, `${locale}.${key}`, defaultMessage);
}

// [...]

const translator = useMemo(() => createTranslator(locale), [locale]);
1 Like