@lingui/macro 3.12.1 → 3.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants.js +4 -2
- package/global.d.ts +1 -0
- package/index.d.ts +1 -0
- package/macroJsx.js +10 -3
- package/package.json +2 -2
package/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.EXTRACT_MARK = exports.COMMENT = exports.MESSAGE = exports.ID = void 0;
|
|
6
|
+
exports.CONTEXT = exports.EXTRACT_MARK = exports.COMMENT = exports.MESSAGE = exports.ID = void 0;
|
|
7
7
|
var ID = "id";
|
|
8
8
|
exports.ID = ID;
|
|
9
9
|
var MESSAGE = "message";
|
|
@@ -11,4 +11,6 @@ exports.MESSAGE = MESSAGE;
|
|
|
11
11
|
var COMMENT = "comment";
|
|
12
12
|
exports.COMMENT = COMMENT;
|
|
13
13
|
var EXTRACT_MARK = "i18n";
|
|
14
|
-
exports.EXTRACT_MARK = EXTRACT_MARK;
|
|
14
|
+
exports.EXTRACT_MARK = EXTRACT_MARK;
|
|
15
|
+
var CONTEXT = "context";
|
|
16
|
+
exports.CONTEXT = CONTEXT;
|
package/global.d.ts
CHANGED
package/index.d.ts
CHANGED
package/macroJsx.js
CHANGED
|
@@ -81,7 +81,8 @@ var MacroJSX = /*#__PURE__*/function () {
|
|
|
81
81
|
var _this$stripMacroAttri = _this.stripMacroAttributes(path.node),
|
|
82
82
|
attributes = _this$stripMacroAttri.attributes,
|
|
83
83
|
id = _this$stripMacroAttri.id,
|
|
84
|
-
comment = _this$stripMacroAttri.comment
|
|
84
|
+
comment = _this$stripMacroAttri.comment,
|
|
85
|
+
context = _this$stripMacroAttri.context;
|
|
85
86
|
|
|
86
87
|
if (!id && !message) {
|
|
87
88
|
return;
|
|
@@ -103,6 +104,10 @@ var MacroJSX = /*#__PURE__*/function () {
|
|
|
103
104
|
if (comment) {
|
|
104
105
|
attributes.push(_this.types.jsxAttribute(_this.types.jsxIdentifier(_constants.COMMENT), _this.types.stringLiteral(comment)));
|
|
105
106
|
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (context) {
|
|
110
|
+
attributes.push(_this.types.jsxAttribute(_this.types.jsxIdentifier(_constants.CONTEXT), _this.types.stringLiteral(context)));
|
|
106
111
|
} // Parameters for variable substitution
|
|
107
112
|
|
|
108
113
|
|
|
@@ -147,7 +152,8 @@ var MacroJSX = /*#__PURE__*/function () {
|
|
|
147
152
|
var id = attributes.filter(_this.attrName([_constants.ID]))[0];
|
|
148
153
|
var message = attributes.filter(_this.attrName([_constants.MESSAGE]))[0];
|
|
149
154
|
var comment = attributes.filter(_this.attrName([_constants.COMMENT]))[0];
|
|
150
|
-
var
|
|
155
|
+
var context = attributes.filter(_this.attrName([_constants.CONTEXT]))[0];
|
|
156
|
+
var reserved = [_constants.ID, _constants.MESSAGE, _constants.COMMENT, _constants.CONTEXT];
|
|
151
157
|
|
|
152
158
|
if (_this.isI18nComponent(node)) {// no reserved prop names
|
|
153
159
|
} else if (_this.isChoiceComponent(node)) {
|
|
@@ -158,6 +164,7 @@ var MacroJSX = /*#__PURE__*/function () {
|
|
|
158
164
|
id: maybeNodeValue(id),
|
|
159
165
|
message: maybeNodeValue(message),
|
|
160
166
|
comment: maybeNodeValue(comment),
|
|
167
|
+
context: maybeNodeValue(context),
|
|
161
168
|
attributes: attributes.filter(_this.attrName(reserved, true))
|
|
162
169
|
};
|
|
163
170
|
});
|
|
@@ -225,7 +232,7 @@ var MacroJSX = /*#__PURE__*/function () {
|
|
|
225
232
|
(0, _defineProperty2.default)(this, "tokenizeChoiceComponent", function (node) {
|
|
226
233
|
var element = node.openingElement;
|
|
227
234
|
var format = element.name.name.toLowerCase();
|
|
228
|
-
var props = element.attributes.filter(_this.attrName([_constants.ID, _constants.COMMENT, _constants.MESSAGE, "key", // we remove <Trans /> react props that are not useful for translation
|
|
235
|
+
var props = element.attributes.filter(_this.attrName([_constants.ID, _constants.COMMENT, _constants.MESSAGE, _constants.CONTEXT, "key", // we remove <Trans /> react props that are not useful for translation
|
|
229
236
|
"render", "component", "components"], true));
|
|
230
237
|
var token = {
|
|
231
238
|
type: "arg",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingui/macro",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.13.0",
|
|
4
4
|
"description": "Macro for generating messages in ICU MessageFormat syntax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": {
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.11.2",
|
|
33
|
-
"@lingui/conf": "^3.
|
|
33
|
+
"@lingui/conf": "^3.13.0",
|
|
34
34
|
"ramda": "^0.27.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|