Oops - do not overwrite keys with values in objects
parent
5c66f487eb
commit
d528779ca5
|
@ -10,8 +10,8 @@ foo = /*#__PURE__*/React.createElement(\\"span\\", null, L(\\"\\\\u041F\\\\u0440
|
||||||
foo = L(\\"У меня много {1}: \\", L(\\"братьев\\"));
|
foo = L(\\"У меня много {1}: \\", L(\\"братьев\\"));
|
||||||
var age = {
|
var age = {
|
||||||
[L(\\"\\\\u0411\\\\u0440\\\\u0430\\\\u0442\\\\u044C\\\\u044F\\")]: {
|
[L(\\"\\\\u0411\\\\u0440\\\\u0430\\\\u0442\\\\u044C\\\\u044F\\")]: {
|
||||||
[L(\\"\\\\u0418\\\\u0432\\\\u0430\\\\u043D\\")]: 32,
|
[L(\\"\\\\u0418\\\\u0432\\\\u0430\\\\u043D\\")]: L(\\"\\\\u0413\\\\u043E\\\\u0440\\\\u044C\\\\u043A\\\\u0438\\\\u0439\\"),
|
||||||
[L(\\"\\\\u041C\\\\u0438\\\\u0445\\\\u0430\\\\u0438\\\\u043B\\")]: 36
|
\\"Mikhail\\": L(\\"\\\\u0417\\\\u043E\\\\u043B\\\\u043E\\\\u0442\\\\u0443\\\\u0445\\\\u0438\\\\u043D\\")
|
||||||
},
|
},
|
||||||
[L(\\"\\\\u0421\\\\u0451\\\\u0441\\\\u0442\\\\u0440\\\\u044B{1}\\", getnum())]: {},
|
[L(\\"\\\\u0421\\\\u0451\\\\u0441\\\\u0442\\\\u0440\\\\u044B{1}\\", getnum())]: {},
|
||||||
Родители
|
Родители
|
||||||
|
|
|
@ -10,7 +10,7 @@ foo = "Меня зовут "+name+"! ";\
|
||||||
foo = ` Меня зовут ${name}!`;\
|
foo = ` Меня зовут ${name}!`;\
|
||||||
foo = <span>Привет!</span>;\
|
foo = <span>Привет!</span>;\
|
||||||
foo = L("У меня много {1}: ", L("братьев"));\
|
foo = L("У меня много {1}: ", L("братьев"));\
|
||||||
var age = { "Братья": { "Иван": 32, "Михаил": 36 }, ["Сёстры"+getnum()]: {}, Родители };\
|
var age = { "Братья": { "Иван": "Горький", "Mikhail": "Золотухин" }, ["Сёстры"+getnum()]: {}, Родители };\
|
||||||
';
|
';
|
||||||
|
|
||||||
it('works', () =>
|
it('works', () =>
|
||||||
|
@ -26,7 +26,8 @@ it('works', () =>
|
||||||
"братьев",
|
"братьев",
|
||||||
"Братья",
|
"Братья",
|
||||||
"Иван",
|
"Иван",
|
||||||
"Михаил",
|
"Горький",
|
||||||
|
"Золотухин",
|
||||||
"Сёстры{1}"
|
"Сёстры{1}"
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
2
index.js
2
index.js
|
@ -165,7 +165,7 @@ module.exports = function(babel)
|
||||||
addImport(path);
|
addImport(path);
|
||||||
let repl = t.callExpression(t.identifier('L'), [ t.stringLiteral(text) ]);
|
let repl = t.callExpression(t.identifier('L'), [ t.stringLiteral(text) ]);
|
||||||
repl = withWhite(lwhite, repl, rwhite);
|
repl = withWhite(lwhite, repl, rwhite);
|
||||||
if (parent.isObjectProperty() && !parent.node.computed)
|
if (parent.isObjectProperty() && path.node == parent.node.key && !parent.node.computed)
|
||||||
parent.replaceWith(t.objectProperty(repl, parent.node.value, true, parent.node.shorthard, parent.node.decorators));
|
parent.replaceWith(t.objectProperty(repl, parent.node.value, true, parent.node.shorthard, parent.node.decorators));
|
||||||
else if (isJSX)
|
else if (isJSX)
|
||||||
path.replaceWith(t.jsxExpressionContainer(repl));
|
path.replaceWith(t.jsxExpressionContainer(repl));
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "babel-plugin-react-translate",
|
"name": "babel-plugin-react-translate",
|
||||||
"version": "1.0.5",
|
"version": "1.0.6",
|
||||||
"description": "Babel-based JS/JSX auto-translator for Russian language",
|
"description": "Babel-based JS/JSX auto-translator for Russian language",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
Loading…
Reference in New Issue