Using with i18next

Using locize with i18next

You can use locize in combination with i18next. I18next is a widely used internationalization framework and offers a wide range of framework integrations and plugins for almost every need.

A) use our custom bundle

Source can be loaded via npm, bower or load it from npm CDN https://unpkg.com/locize@^1.0.0.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import locize from 'locize';
locize.init({
lng: 'en',
fallbacklng: 'en',
backend: {
projectId: '[PROJECT_ID]',
apiKey: '[API_KEY]',
referenceLng: 'en'
}
}, (err, t) => {
// initialized and ready to go!
const hw = locize.t('key'); // hw = 'hello world'
});

(You can find your projectId and API Key in your projects settings under the API Tab.)

For more information visit the i18next website:

Just replace i18next with locize on use.

B) use our plugin with i18next

Alternatively use the plugins we offer with i18next:

code Browser

Just use the i18next-locize-backend

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import i18next from 'i18next';
import Backend from 'i18next-locize-backend';
i18next
.use(Backend)
.init({
// ...other options
backend: {
projectId: '[PROJECT_ID]',
apiKey: '[API_KEY]',
referenceLng: '[LNG]'
}
});

(You can find your projectId and API Key in your projects settings under the API Tab.)

Find more details and configuration options on the github page.

code node.js

Just use the i18next-node-locize-backend

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import i18next from 'i18next';
import Backend from 'i18next-node-locize-backend';
i18next
.use(Backend)
.init({
// ...other options
backend: {
projectId: '[PROJECT_ID]',
apiKey: '[API_KEY]',
referenceLng: '[LNG]'
}
});

Find more details and configuration options on the github page.


Have questions? Contact us!

Share