@talend/locales-tui-dataviz
v3.0.1
Published
This module contains i18n files for tui-dataviz project.
Downloads
626
Readme
tui-dataviz locales
This module contains i18n files for tui-dataviz project.
How to install
yarn add @talend/locales-tui-dataviz
or
npm install @talend/locales-tui-dataviz
How to use with i18next
Synchronous use
i18n.js
import i18n from 'i18next';
import merge from 'lodash/merge';
import { namespaces as tuidatavizNamespaces } from '@talend/locales-tui-dataviz/namespaces';
import { locales as tuidatavizLocales } from '@talend/locales-tui-dataviz/locales';
i18n
.init({
ns: [
...tuidatavizNamespaces,
...myProjectNamespaces
],
resources: merge(tuidatavizLocales, myProjectLocales),
});
export default i18n;
Asynchronous use
For async load, you need to copy the i18n files to the location you want to serve them
webpack.config.js
const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
plugins: [
new CopyWebpackPlugin([
{ from: 'node_modules/@talend/locales-tui-dataviz/locales', to: 'assets/locales' },
]),
]
}
i18n.js
import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import { namespaces as tuidatavizNamespaces } from '@talend/locales-tui-dataviz/namespaces';
i18n
.use(XHR)
.init({
ns: [
...tuidatavizNamespaces,
...myProjectNamespaces
],
backend: {
loadPath: '/assets/locales/{{lng}}/{{ns}}.json',
},
});
export default i18n;