0.0.3 • Published 4 years ago

csv-to-language-files v0.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

csv-to-language-files

csv 文件转换为多个 language 文件

使用示例

web.csv 文件示例

示例或说明,key,zh-Hans,en
确认动作,action.confirm,确认,confirm
取消动作,action.cancel,取消,cancel
const path = require('path');
const csvToLanguageFiles = require('../src/index.js');

csvToLanguageFiles(
    path.join(__dirname, './web.csv'),
    {
        outputDir: __dirname,
        fileType: 'js',
        ignoreColumns: [0],
        keyColumn: 1,
        fold: true
    }
).then(resp => {
    console.warn(resp);
    console.warn('全部写入完成了');
}).catch(error => {
    console.warn(error);
    console.warn('全部写入失败了');
});

参数说明

调用 csvToLanguageFiles(file, option):

参数类型是否必传默认值说明
fileStringundefinedcsv 文件绝对路径
optionObjectundefined写入选项

写入选项 option:

参数类型是否必传默认值说明
outputDirStringundefined输出目录
fileTypeStringjs如果是 js 文件,可直接引用,json、txt 以及任意类型均可
ignoreColumnsArray[]忽略的列
keyColumnNumber0语言 key 标识列
foldBooleantrue对象中包含对象时是否折叠输出