Created
October 5, 2020 08:10
-
-
Save nothingrealhappen/d985e5f92805f10bfc57bf85800ad83e to your computer and use it in GitHub Desktop.
translate simplified chinese to traditional chinese
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _ = require('lodash') | |
var convert = require('chinese_convert') | |
const data = { | |
"message": { | |
"delete": "您要刪除此訪客嗎?" | |
}, | |
"otherKeys": { | |
"supportNested": "支持嵌套的字段" | |
} | |
} | |
const mapValuesDeep = (v, callback) => ( | |
_.isObject(v) | |
? _.mapValues(v, v => mapValuesDeep(v, callback)) | |
: callback(v) | |
) | |
const result = mapValuesDeep(data, val => convert.cn2tw(val)) | |
console.log('----------') | |
console.log(JSON.stringify(result)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment