@talend/locales-tui-forms
v15.2.0
Published
This module contains i18n files for TUI-forms project.
Downloads
1,633
Readme
TUI-forms locales
This module contains i18n files for TUI-forms project.
How to install
yarn add @talend/locales-tui-forms
or
npm install @talend/locales-tui-forms
How to use with i18next
Synchronous use
i18n.js
import i18n from 'i18next';
import merge from 'lodash/merge';
import { namespaces as tuiformsNamespaces } from '@talend/locales-tui-forms/namespaces';
import { locales as tuiformsLocales } from '@talend/locales-tui-forms/locales';
i18n
.init({
ns: [
...tuiformsNamespaces,
...myProjectNamespaces
],
resources: merge(tuiformsLocales, 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-forms/locales', to: 'assets/locales' },
]),
]
}
i18n.js
import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import { namespaces as tuiformsNamespaces } from '@talend/locales-tui-forms/namespaces';
i18n
.use(XHR)
.init({
ns: [
...tuiformsNamespaces,
...myProjectNamespaces
],
backend: {
loadPath: '/assets/locales/{{lng}}/{{ns}}.json',
},
});
export default i18n;