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.2 to 1.0.3

test.xlsx

17

index.js

@@ -10,3 +10,3 @@ #!/usr/bin/env node

const { exit } = require('process')
const { getJSON, generateWindowsV2 } = require('./main')
const { generateAndroid, generateWindowsV2, generateIOS } = require('./main')

@@ -20,4 +20,4 @@ const packageStr = fs.readFileSync(path.join(__dirname, './package.json'), 'utf-8')

program
.command('translate <project>')
.description('init project')
.command('translate <xlsx>')
.description('translate excel to coder')
.action(function (projectName) {

@@ -29,3 +29,3 @@ // 与用户交互

type: 'list',
choices: ['windows', 'ios'],
choices: ['windows', 'ios|mac', 'android', 'android-ctrl'],
name: 'terminal',

@@ -43,6 +43,9 @@ message: chalk.blue('请选择输出语言包的类型 :')

const data = getJSON(xlsx.parse(projectName))
const data = xlsx.parse(projectName)
if (answers.terminal === 'windows') {
generateWindowsV2(data.zh, data.en)
switch (answers.terminal) {
case 'windows': return generateWindowsV2(data);
case 'ios|mac': return generateIOS(data);
case 'android': return generateAndroid(data,6);
case 'android-ctrl': return generateAndroid(data,7);

@@ -49,0 +52,0 @@ }

const tool = require('node-xlsx')
const fs = require('fs')
// const data = tool.parse('./lang.xlsx')
// const HomeSheet = data[0].data
// 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]
// }
// })
exports.getJSON = function (data) {
const getJSON = function (data, number) {
const HomeSheet = data[0].data

@@ -26,4 +13,8 @@

if (index > 0) {
windows_en[item[5]] = item[1]
windows_zh[item[5]] = item[0]
if (Boolean(item[number])) {
const key = item[number].replaceAll('\n', '')
windows_en[key] = item[1]
windows_zh[key] = item[0]
}
}

@@ -37,3 +28,5 @@ })

exports.generateWindowsV2 = function (windows_zh, windows_en) {
exports.generateWindowsV2 = function (data) {
const { zh, en } = getJSON(data, 5)
const windowsModal = content => `

@@ -115,9 +108,9 @@ <?xml version="1.0" encoding="utf-8"?>

for (const item in windows_en) {
en_content = en_content + model(item, windows_en[item])
for (const item in en) {
en_content = en_content + model(item, en[item])
}
for (const item in windows_zh) {
zh_content = zh_content + model(item, windows_zh[item])
for (const item in zh) {
zh_content = zh_content + model(item, zh[item])
}

@@ -132,7 +125,5 @@

}
// generateWindowsV2()
function generateIOS () {
exports.generateIOS = function (data) {
const { zh, en } = getJSON(data, 6)
const model = (key, value) => `"${key}" = "${value}";`

@@ -143,23 +134,64 @@

for (const item in windows_en) {
en_content = en_content + model(item, windows_en[item]) + '\n'
for (const item in en) {
en_content = en_content + model(item, en[item]) + '\n'
}
for (const item in windows_zh) {
zh_content = zh_content + model(item, windows_zh[item]) + '\n'
for (const item in zh) {
zh_content = zh_content + model(item, zh[item]) + '\n'
}
fs.writeFile(`./ios/Localizable_en.strings`, en_content, err => {
console.log(`写入ios英文资源文件成功`)
fs.writeFile(`./Localizable_en.strings`, en_content, err => {
console.log(`写入ios中文资源文件成功`)
})
fs.writeFile(`./ios/Localizable_zh.strings`, zh_content, err => {
fs.writeFile(`./Localizable_zh.strings`, zh_content, err => {
console.log(`写入ios英文资源文件成功`)
})
}
exports.generateAndroid = function (data, number) {
const { zh, en } = getJSON(data, number)
const model = (key, value) => `<string name="${key}">${value}</string>`
let en_content = ''
let zh_content = ''
for (const item in en) {
en_content = en_content + model(item, en[item]) + '\n'
}
for (const item in zh) {
zh_content = zh_content + model(item, zh[item]) + '\n'
}
const en_Content =
`
<resources>
${en_content}
</resources>
`
const zh_Content =
`
<resources>
${zh_content}
</resources>
`
const enName = `./Android${number === 7 ? '_Ctrl' : ''}_en.xml`
const zhName = `./Android${number === 7 ? '_Ctrl' : ''}_zh.xml`
fs.writeFile(enName, en_Content, err => {
console.log(`写入Android英文资源文件成功`)
})
fs.writeFile(zhName, zh_Content, err => {
console.log(`写入Android中文资源文件成功`)
})
}
// generateIOS()
{
"name": "eshare-locale-bin",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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