i18n处理进一步强化

This commit is contained in:
Xu Chang 2024-06-07 18:43:47 +08:00
parent 6100bfa503
commit 77ec173fbd
1 changed files with 25 additions and 2 deletions

View File

@ -167,7 +167,30 @@ module.exports = (babel) => {
if (arg1) { if (arg1) {
// 一般是对象,也可能是变量,表达式不予考虑 // 一般是对象,也可能是变量,表达式不予考虑
if (t.isObjectExpression(arg1)) { // 加上Object.assign({ '#oakNamespace': xxx, '#oakModule': xxx }, arg1);
if (t.isCallExpression(arg1) && t.isMemberExpression(arg1.name) && t.isIdentifier(arg1.name.object)
&& arg1.name.object.name === 'Object' && t.isIdentifier(arg1.name.property) && arg1.name.property.name === 'assign') {
// 不处理,这里似乎会被反复调用,不知道为什么
}
else {
arguments.splice(1, 1, t.callExpression(
t.memberExpression(
t.identifier('Object'),
t.identifier('assign')
),
[
t.objectExpression(
[
t.objectProperty(t.stringLiteral(oakNsPropName), t.stringLiteral(ns)),
t.objectProperty(t.stringLiteral(oakModulePropName), t.stringLiteral(moduleName))
]
),
arg1
]
));
}
/* if (t.isObjectExpression(arg1)) {
const { properties } = arg1; const { properties } = arg1;
const oakNsProp = properties.find( const oakNsProp = properties.find(
ele => t.isStringLiteral(ele.key) && ele.key.value === oakNsPropName ele => t.isStringLiteral(ele.key) && ele.key.value === oakNsPropName
@ -198,7 +221,7 @@ module.exports = (babel) => {
} }
else { else {
// 不处理,这里似乎会反复调用,不知道为什么 // 不处理,这里似乎会反复调用,不知道为什么
} } */
} }
else { else {
// 如果无参数就构造一个对象传入 // 如果无参数就构造一个对象传入