mirror of
https://github.com/zuiidea/antd-admin.git
synced 2024-04-21 12:32:14 +00:00
🐛 Fix cannot translate fields with variables.
This commit is contained in:
+15
-3
@@ -56,9 +56,21 @@ const transform = async ({ from, to, locales, outputPath }) => {
|
||||
let res = key
|
||||
let way = 'youdao'
|
||||
if (key.indexOf('/') !== 0) {
|
||||
res = await youdao({
|
||||
q: key,
|
||||
})
|
||||
const reg = '{([^{}]*)}'
|
||||
const tasks = key
|
||||
.match(new RegExp(`${reg}|((?<=(${reg}|^)).*?(?=(${reg}|$)))`, 'g'))
|
||||
.map(item => {
|
||||
if (new RegExp(reg).test(item)) {
|
||||
return Promise.resolve(item)
|
||||
}
|
||||
return youdao({
|
||||
q: item,
|
||||
from,
|
||||
to,
|
||||
})
|
||||
})
|
||||
|
||||
res = (await Promise.all(tasks)).join('')
|
||||
} else {
|
||||
res = `/${to + key}`
|
||||
way = 'link'
|
||||
|
||||
Reference in New Issue
Block a user