1.0.0 • Published 1 year ago

@coderoot/i18next-util v1.0.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

@coderoot/i18next-util

Setup

  • create a /locales directory at the root of the project
  • add "locales" in the files configuration of the package.json library
  • create .json files for each languages
  • add /public/locales to.gitignore (react-script will take care of populating this directory with builded .json files)

Build

By calling buildI18nResources, every dependencies that has a locales directory will be copied into the public directory. In case of multiple versions of a dependency, the resources will be merged, and in case a conflicting key in resource, the greatest version win. (using lodash/merge)

import { buildI18nResources } from '@coderoot/i18next-util';

buildI18nResources();

Test

You can gather all the resources by calling getI18nResources.

⚠️ Be aware that it will only work in a node environment, for testing purpose.

import { getI18nResources } from '@coderoot/i18next-util';

i18next.init({
  resources = getI18nResources()
})
1.0.0

1 year ago