Skip to content

Commit

Permalink
update: about username (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
biuuu authored Jun 12, 2018
1 parent 16b76f6 commit d96f3a7
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
3 changes: 2 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ const config = {
transScenario: true,
// 否启用界面翻译
transUi: true,
// 是否替换主角名字,不替换留空
// 替换用的主角名字
yourName: '姬塔',
displayName: '',
// 是否拦截 http://platform.twitter.com/widgets.js
interceptTwitterWidgets: true,

Expand Down
12 changes: 6 additions & 6 deletions modules/translate/scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ const replaceChar = (key, item, map) => {
if (/\s?[\?0-9]{1,2}$/.test(name)) {
// name with number or symbol
const nameRst = name.match(/(.+)\s?([\?0-9]{1,2})$/)
trans = map.get(nameRst[1])
const _trans = map.get(nameRst[1])
_name = nameRst[1]
if (trans) trans += nameRst[2]
if (_trans) trans = `${_trans}${nameRst[2]}`
} else if (/'s\sVoice$/.test(name)) {
let nmKey = name.slice(0, name.length - 8)
trans = map.get(nmKey)
if (trans) trans += '的声音'
const _trans = map.get(nmKey)
if (_trans) trans = `${_trans}的声音`
} else if (/$/.test(name)) {
let nmKey = name.slice(0, name.length - 2)
trans = map.get(nmKey)
if (trans) trans += '的声音'
const _trans = map.get(nmKey)
if (_trans) trans = `${_trans}的声音`
}

if (trans) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blhxfy",
"version": "0.5.8",
"version": "0.5.9",
"description": "碧蓝幻想微风机翻团",
"main": "main.js",
"scripts": {
Expand Down
3 changes: 0 additions & 3 deletions renderer/form-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ Vue.component('form-config', {
</el-switch>
<span style="margin-left:4px;font-size:12px;color:#f56c6c">重启后生效</span>
</el-form-item>
<el-form-item label="监控页端口">
<el-input-number v-model="configForm.webPort" :min="1" :max="65535"></el-input-number>
</el-form-item>
<el-form-item label="替换静态文件">
<el-switch
v-model="configForm.staticServer"
Expand Down
2 changes: 1 addition & 1 deletion utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const replaceWords = (str, map, lang = 'en') => {
if (!str) return str
let _str = str
for (let [key, val] of map) {
if (!key || key.length < 3) continue
if (!key || key.length < 2) continue
const expr = key.replace(/\?/g, '\\?').replace(/\./g, '\\.').replace(/\*/g, '\\*').replace(/\+/g, '\\+')
const reStr = lang === 'en' ? `\\b${expr}\\b` : `${expr}`
if (typeof val === 'string') {
Expand Down
6 changes: 3 additions & 3 deletions utils/readScenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { readCsv, replaceWords } = require('./index')
const { USER_DATA_PATH, dataPath } = require('../store/')

const readScenario = async ({ filename, stable }, userName) => {
const csvPath = stable
const csvPath = stable
? path.resolve(await dataPath(), './scenario', `${filename}`)
: path.resolve(USER_DATA_PATH, `local/scenario`, `${filename}`)
const list = await readCsv(csvPath)
Expand All @@ -15,11 +15,11 @@ const readScenario = async ({ filename, stable }, userName) => {
const id = idArr[0]
const type = idArr[1] || 'detail'
const obj = transMap.get(id) || {}
obj[type] = replaceWords(item.trans, new Map([[CONFIG.yourName, userName]]), 'zh')
obj[type] = replaceWords(item.trans, new Map([[CONFIG.yourName, CONFIG.displayName || userName || '古兰']]), 'zh')
transMap.set(id, obj)
}
})
return transMap
}

module.exports = readScenario
module.exports = readScenario

0 comments on commit d96f3a7

Please sign in to comment.