-
Notifications
You must be signed in to change notification settings - Fork 4
locales
axios edited this page Sep 21, 2021
·
3 revisions
Get details from the code.
- require
const { locales } = require('@axiosleo/cli-tool');
- init
locales.init({
dir: path.join(__dirname, '../locales'), // The path to the language packs directory
sets: ['en-US', 'zh-CN'], // The first language set is the default
});
- specifies the language set
locales.use('en-US');
- translate word
const { __ } = require('@axiosleo/cli-tool').locales;
console.log(__('some word'));
- complete demo
const { init, __, use } = require('@axiosleo/cli-tool').locales;
init({
dir: path.join(__dirname, '../locales'),
sets: ['en-US', 'zh-CN'], // The first language set is the default
});
// select the language set according to the system environment
console.log(__('some word'));
// specifies the language set
use('en-US');
console.log(__('use en-US language set to translate'));
Anything unclear or inaccurate? Please let me know at [email protected]