New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eshare-locale-bin

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eshare-locale-bin - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

47

index.js
#!/usr/bin/env node
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 { exit } = require('process')
const { getJSON, generateWindowsV2 } = require('./main')
const data = xlsx.parse('./lang.xlsx')
const packageStr = fs.readFileSync(path.join(__dirname, './package.json'), 'utf-8')
const version = JSON.parse(packageStr).version
console.log(data)
program
.version(version, '-v, --version')
program
.command('translate <project>')
.description('init project')
.action(function (projectName) {
// 与用户交互
inquirer
.prompt([
{
type: 'list',
choices: ['windows', 'ios'],
name: 'terminal',
message: chalk.blue('请选择输出语言包的类型 :')
}
])
.then(answers => {
const fileType = projectName.split('.').pop()
if (fileType !== 'xlsx') {
console.log(chalk.red(`请确认文件为xlsx结尾的、标准的excel格式文件!`))
exit(0)
}
const data = getJSON(xlsx.parse(projectName))
if (answers.terminal === 'windows') {
generateWindowsV2(data.zh, data.en)
}
})
})
program.parse(process.argv)

45

main.js
const tool = require('node-xlsx')
const fs = require('fs')
const data = tool.parse('./lang.xlsx')
// const data = tool.parse('./lang.xlsx')
const HomeSheet = data[0].data
// const HomeSheet = data[0].data
const windows_en = {}
const windows_zh = {}
// const windows_en = {}
// const windows_zh = {}
HomeSheet.forEach((item, index) => {
if (index > 0) {
windows_en[item[5]] = item[1]
windows_zh[item[5]] = item[0]
}
})
// HomeSheet.forEach((item, index) => {
// if (index > 0) {
// windows_en[item[5]] = item[1]
// windows_zh[item[5]] = item[0]
// }
// })
exports.getJSON = function(data){
exports.getJSON = function (data) {
const HomeSheet = data[0].data

@@ -23,3 +23,3 @@

const windows_zh = {}
HomeSheet.forEach((item, index) => {

@@ -31,6 +31,9 @@ if (index > 0) {

})
console.log(windows_en)
return ({
en: windows_en,
zh: windows_zh
})
}
function generateWindowsV2 () {
exports.generateWindowsV2 = function (windows_zh, windows_en) {
const windowsModal = content => `

@@ -121,6 +124,6 @@ <?xml version="1.0" encoding="utf-8"?>

fs.writeFile(`./windows/Win_Resource_en.resx`, windowsModal(en_content), err => {
fs.writeFile(`./Win_Resource_en.resx`, windowsModal(en_content), err => {
console.log(`写入windows英文资源文件成功`)
})
fs.writeFile(`./windows/Win_Resource_zh.resx`, windowsModal(zh_content), err => {
fs.writeFile(`./Win_Resource_zh.resx`, windowsModal(zh_content), err => {
console.log(`写入windows中文资源文件成功`)

@@ -133,4 +136,4 @@ })

function generateIOS(){
const model = (key,value) => `"${key}" = "${value}";`
function generateIOS () {
const model = (key, value) => `"${key}" = "${value}";`

@@ -149,7 +152,7 @@ let en_content = ''

fs.writeFile(`./ios/Localizable_en.strings`, en_content, err => {
console.log(`写入windows英文资源文件成功`)
console.log(`写入ios英文资源文件成功`)
})
fs.writeFile(`./ios/Localizable_zh.strings`, zh_content, err => {
console.log(`写入windows英文资源文件成功`)
console.log(`写入ios英文资源文件成功`)
})

@@ -163,3 +166,1 @@

exports.generateWindows = generateWindowsV2
{
"name": "eshare-locale-bin",
"version": "1.0.1",
"version": "1.0.2",
"description": "",

@@ -17,4 +17,5 @@ "main": "index.js",

"commander": "^7.1.0",
"inquirer": "^8.2.0",
"node-xlsx": "^0.21.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc