Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@scaleflex/i18n-it

Package Overview
Dependencies
Maintainers
0
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scaleflex/i18n-it

Backend plugin to load data via i18n.it service for i18next

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
0
Created
Source

Contributions welcome License Scaleflex team

@scaleflex/i18n-it

Backend plugin to load data via i18n.it service for i18next

Install

npm i @scaleflex/i18n-it --save

usage

i18n.client.js

import i18n from 'i18next';
import Backend from '@scaleflex/i18n-it';

const newInstance = i18n.createInstance();  // create new instance (helpful if you have nested i18nProviders)

newInstance
  .use(Backend)
  .init({
    fallbackLng: false,
    lng: 'en',                  // initial language
    ns: ['translations'],
    defaultNS: 'translations',
    debug: false,
    load: 'languageOnly',
    keySeparator: false,
    nsSeparator: false,
    saveMissing: true,
    react: {
      wait: true
    },
    backend: {
      uuid: 'xxx'                // your grid key in i18n.it service
    }
  });


export default newInstance;

in your index.js

...
// import I18nextProvider from react-i18next and i18n from i18n.client.js
import { I18nextProvider } from 'react-i18next';
import i18n from './i18nIt/i18n.client'


ReactDOM.render(
  <I18nextProvider i18n={i18n}>  // wrap your app with I18nextProvider and pass i18n module
    <Suspense fallback="loading">
      <App/>
    </Suspense>
  </I18nextProvider>,
  document.getElementById('root')
);

! make sure you use the correct language formats everywhere in your app. Different formats like “fr” / “fr-FR” / “fr-fr” will cause to extra API call.

check the documentation for i18next

Contributing!

All contributions are super welcome!

License

@scaleflex/i18n-it is provided under the MIT License

FAQs

Package last updated on 16 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts