eshare-locale-bin
Advanced tools
Comparing version 2.0.1 to 2.1.0
42
index.js
#!/usr/bin/env node | ||
const fs = require('fs') | ||
const path = require('path') | ||
const program = require('commander') | ||
const fs = require('fs') | ||
const path = require('path') | ||
const program = require('commander') | ||
const inquirer = require('inquirer') | ||
const chalk = require('chalk') | ||
const xlsx = require('node-xlsx') | ||
const chalk = require('chalk') | ||
const xlsx = require('node-xlsx') | ||
const { exit } = require('process') | ||
const { generateAndroid, generateWindowsV2, generateIOS,generateWeb } = require('./main') | ||
const { | ||
generateAndroid, | ||
generateWindowsV2, | ||
generateIOS, | ||
generateWeb } = require('./main') | ||
const packageStr = fs.readFileSync(path.join(__dirname, './package.json'), 'utf-8') | ||
const version = JSON.parse(packageStr).version | ||
const version = JSON.parse(packageStr).version | ||
@@ -18,3 +21,14 @@ program | ||
program | ||
.command('example') | ||
.description('print an example header') | ||
.action(function () { | ||
console.log(chalk.blue('Excel示例:(index)这一列不需要出现在Excel中')) | ||
console.table([ | ||
{ 中文: "示例中文", 英文: "Example English", 资源key值: "resourceKey" } | ||
]); | ||
}); | ||
program | ||
.command('translate <xlsx>') | ||
@@ -27,5 +41,5 @@ .description('translate excel to coder') | ||
{ | ||
type: 'list', | ||
type : 'list', | ||
choices: ['windows', 'ios', 'mac', 'android', 'web'], | ||
name: 'terminal', | ||
name : 'terminal', | ||
message: chalk.blue('请选择输出语言包的类型 :') | ||
@@ -46,5 +60,5 @@ } | ||
case 'windows': return generateWindowsV2(data); | ||
case 'ios': return generateIOS(data, 2); | ||
case 'mac': return generateIOS(data, 2); | ||
case 'web': return generateWeb(data, 2); | ||
case 'ios' : return generateIOS(data, 2); | ||
case 'mac' : return generateIOS(data, 2); | ||
case 'web' : return generateWeb(data, 2); | ||
case 'android': return generateAndroid(data, 2); | ||
@@ -59,1 +73,3 @@ // case 'android-ctrl': return generateAndroid(data, 2); | ||
program.parse(process.argv) | ||
25
main.js
const tool = require('node-xlsx') | ||
const fs = require('fs') | ||
const fs = require('fs') | ||
//中文放在第一列、英文放在第二列、key放在第三列 | ||
const getJSON = function (data, number) { | ||
const HomeSheet = data[0].data | ||
console.log(number) | ||
const HomeSheet = data[0].data | ||
const windows_en = {} | ||
@@ -14,5 +15,6 @@ const windows_zh = {} | ||
if (index > 0) { | ||
console.log(item) | ||
if (Boolean(item[number])) { | ||
const key = item[number].replaceAll('\n', '') | ||
windows_en[key] = item[1] | ||
const key = item[number].toString().replaceAll('\n', '') | ||
windows_en[key] = item[1] | ||
windows_zh[key] = item[0] | ||
@@ -125,7 +127,6 @@ } | ||
const { zh, en } = getJSON(data, number) | ||
const model = (key, value) => `"${key}" = "${value}";` | ||
const model = (key, value) => `"${key}" = "${value}";` | ||
let en_content = '' | ||
let zh_content = '' | ||
let en_content = '' | ||
let zh_content = '' | ||
for (const item in en) { | ||
@@ -187,3 +188,3 @@ en_content = en_content + model(item, en[item]) + '\n' | ||
const { zh, en } = getJSON(data, number) | ||
const model = (key, value) => `<string name="${key}">${value}</string>` | ||
const model = (key, value) => `<string name="${key}">${value}</string>` | ||
@@ -201,3 +202,3 @@ let en_content = '' | ||
const en_Content = | ||
const en_Content = | ||
` | ||
@@ -209,3 +210,3 @@ <resources> | ||
const zh_Content = | ||
const zh_Content = | ||
` | ||
@@ -212,0 +213,0 @@ <resources> |
{ | ||
"name": "eshare-locale-bin", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"description": "", | ||
@@ -21,2 +21,2 @@ "main": "index.js", | ||
} | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8812
240