@tonyptang/generate-i18n
v1.1.2
Published
generate config for i18n
Downloads
5
Readme
generate-i18n
generate config for i18n
npm i @tonyptang/generate-i18n (-g)
use: gi --config or gi -c to Specify the configuration file
// gi.config.(t|j)s
import { join } from 'path'
import { defineConfig } from './src/index'
const filename = join(__dirname, './t.xlsx') // your xlsx file
export default defineConfig([
{
sheetName: 'lang 1',
propDict: {
2: 'jump.tips', // start line
3: 'submit.nickname',
3: {
propName: 'eee.aaa',
variableList: [
{
variableName: 'day',
variableValue: '%d',
}, // Object
[/%d|10/g, 'fff'] // array
]
},
// The matched string is processed specially
3: ({ value, setVariable, config: { variableTemplate } }) => {
const [title, ...mainContent] = matched.split('\n').filter(Boolean)
const content = mainContent.join('\n')
return {
'prop1.title': title,
'prop1.content': setVariable({
variableName: 'prop1',
variableValue: '[email protected]',
variableTemplate,
origin: content,
}),
}
}, // function
},
langDict: {
A: 'en.js',
B: 'id.js',
C: 'ar.js',
},
filename,
outDir: './i18n',
},
])