babel-plugin-formatjs 10.3.25 → 10.3.26
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/BUILD +90 -0
- package/CHANGELOG.md +1139 -0
- package/LICENSE.md +0 -0
- package/README.md +0 -0
- package/global.d.ts +0 -0
- package/index.ts +88 -0
- package/integration-tests/BUILD +21 -0
- package/integration-tests/package.json +5 -0
- package/integration-tests/vue/fixtures/App.vue +19 -0
- package/integration-tests/vue/fixtures/app.js +6 -0
- package/integration-tests/vue/integration.test.ts +62 -0
- package/package.json +5 -4
- package/tests/__snapshots__/index.test.ts.snap +1246 -0
- package/tests/fixtures/2663.js +3 -0
- package/tests/fixtures/FormattedMessage.js +14 -0
- package/tests/fixtures/additionalComponentNames.js +15 -0
- package/tests/fixtures/additionalFunctionNames.js +23 -0
- package/tests/fixtures/ast.js +45 -0
- package/tests/fixtures/defineMessage.js +57 -0
- package/tests/fixtures/defineMessages.js +49 -0
- package/tests/fixtures/descriptionsAsObjects.js +18 -0
- package/tests/fixtures/empty.js +8 -0
- package/tests/fixtures/extractFromFormatMessageCall.js +47 -0
- package/tests/fixtures/extractFromFormatMessageCallStateless.js +46 -0
- package/tests/fixtures/extractSourceLocation.js +8 -0
- package/tests/fixtures/formatMessageCall.js +38 -0
- package/tests/fixtures/icuSyntax.js +18 -0
- package/tests/fixtures/idInterpolationPattern.js +40 -0
- package/tests/fixtures/inline.js +26 -0
- package/tests/fixtures/overrideIdFn.js +48 -0
- package/tests/fixtures/preserveWhitespace.js +79 -0
- package/tests/fixtures/removeDefaultMessage.js +36 -0
- package/tests/fixtures/skipExtractionFormattedMessage.js +12 -0
- package/tests/fixtures/templateLiteral.js +21 -0
- package/tests/index.test.ts +221 -0
- package/tsconfig.json +5 -0
- package/types.ts +46 -0
- package/utils.ts +226 -0
- package/visitors/call-expression.ts +208 -0
- package/visitors/jsx-opening-element.ts +147 -0
- package/index.d.ts +0 -10
- package/index.d.ts.map +0 -1
- package/index.js +0 -74
- package/types.d.ts +0 -31
- package/types.d.ts.map +0 -1
- package/types.js +0 -2
- package/utils.d.ts +0 -34
- package/utils.d.ts.map +0 -1
- package/utils.js +0 -155
- package/visitors/call-expression.d.ts +0 -6
- package/visitors/call-expression.d.ts.map +0 -1
- package/visitors/call-expression.js +0 -127
- package/visitors/jsx-opening-element.d.ts +0 -6
- package/visitors/jsx-opening-element.d.ts.map +0 -1
- package/visitors/jsx-opening-element.js +0 -89
|
@@ -0,0 +1,1246 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`FormattedMessage 1`] = `
|
|
4
|
+
Object {
|
|
5
|
+
"code": "import React, { Component } from 'react';
|
|
6
|
+
import { FormattedMessage } from 'react-intl';
|
|
7
|
+
export default class Foo extends Component {
|
|
8
|
+
render() {
|
|
9
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
10
|
+
id: \\"foo.bar.baz\\",
|
|
11
|
+
defaultMessage: \\"Hello World!\\"
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}",
|
|
16
|
+
"data": Object {
|
|
17
|
+
"messages": Array [
|
|
18
|
+
Object {
|
|
19
|
+
"defaultMessage": "Hello World!",
|
|
20
|
+
"description": "The default message.",
|
|
21
|
+
"id": "foo.bar.baz",
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
"meta": Object {},
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`GH #2663 1`] = `
|
|
30
|
+
Object {
|
|
31
|
+
"code": "\\"use strict\\";
|
|
32
|
+
|
|
33
|
+
function _typeof(obj) { \\"@babel/helpers - typeof\\"; return _typeof = \\"function\\" == typeof Symbol && \\"symbol\\" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && \\"function\\" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? \\"symbol\\" : typeof obj; }, _typeof(obj); }
|
|
34
|
+
|
|
35
|
+
function _regeneratorRuntime() { \\"use strict\\"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = \\"function\\" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || \\"@@iterator\\", asyncIteratorSymbol = $Symbol.asyncIterator || \\"@@asyncIterator\\", toStringTagSymbol = $Symbol.toStringTag || \\"@@toStringTag\\"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, \\"\\"); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = \\"suspendedStart\\"; return function (method, arg) { if (\\"executing\\" === state) throw new Error(\\"Generator is already running\\"); if (\\"completed\\" === state) { if (\\"throw\\" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if (\\"next\\" === context.method) context.sent = context._sent = context.arg;else if (\\"throw\\" === context.method) { if (\\"suspendedStart\\" === state) throw state = \\"completed\\", context.arg; context.dispatchException(context.arg); } else \\"return\\" === context.method && context.abrupt(\\"return\\", context.arg); state = \\"executing\\"; var record = tryCatch(innerFn, self, context); if (\\"normal\\" === record.type) { if (state = context.done ? \\"completed\\" : \\"suspendedYield\\", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } \\"throw\\" === record.type && (state = \\"completed\\", context.method = \\"throw\\", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: \\"normal\\", arg: fn.call(obj, arg) }; } catch (err) { return { type: \\"throw\\", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { [\\"next\\", \\"throw\\", \\"return\\"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if (\\"throw\\" !== record.type) { var result = record.arg, value = result.value; return value && \\"object\\" == _typeof(value) && hasOwn.call(value, \\"__await\\") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke(\\"next\\", value, resolve, reject); }, function (err) { invoke(\\"throw\\", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke(\\"throw\\", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, \\"throw\\" === context.method) { if (delegate.iterator[\\"return\\"] && (context.method = \\"return\\", context.arg = undefined, maybeInvokeDelegate(delegate, context), \\"throw\\" === context.method)) return ContinueSentinel; context.method = \\"throw\\", context.arg = new TypeError(\\"The iterator does not provide a 'throw' method\\"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if (\\"throw\\" === record.type) return context.method = \\"throw\\", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, \\"return\\" !== context.method && (context.method = \\"next\\", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = \\"throw\\", context.arg = new TypeError(\\"iterator result is not an object\\"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = \\"normal\\", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: \\"root\\" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if (\\"function\\" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, \\"constructor\\", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, \\"constructor\\", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, \\"GeneratorFunction\\"), exports.isGeneratorFunction = function (genFun) { var ctor = \\"function\\" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || \\"GeneratorFunction\\" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, \\"GeneratorFunction\\")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, \\"Generator\\"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, \\"toString\\", function () { return \\"[object Generator]\\"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = \\"next\\", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { \\"t\\" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if (\\"throw\\" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = \\"throw\\", record.arg = exception, context.next = loc, caught && (context.method = \\"next\\", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if (\\"root\\" === entry.tryLoc) return handle(\\"end\\"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, \\"catchLoc\\"), hasFinally = hasOwn.call(entry, \\"finallyLoc\\"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error(\\"try statement without catch or finally\\"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, \\"finallyLoc\\") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && (\\"break\\" === type || \\"continue\\" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = \\"next\\", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if (\\"throw\\" === record.type) throw record.arg; return \\"break\\" === record.type || \\"continue\\" === record.type ? this.next = record.arg : \\"return\\" === record.type ? (this.rval = this.arg = record.arg, this.method = \\"return\\", this.next = \\"end\\") : \\"normal\\" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, \\"catch\\": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if (\\"throw\\" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error(\\"illegal catch attempt\\"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, \\"next\\" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
36
|
+
|
|
37
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
38
|
+
|
|
39
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"next\\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \\"throw\\", err); } _next(undefined); }); }; }
|
|
40
|
+
|
|
41
|
+
function error1() {
|
|
42
|
+
return _error.apply(this, arguments);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function _error() {
|
|
46
|
+
_error = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
47
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
48
|
+
while (1) {
|
|
49
|
+
switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
51
|
+
_context.next = 2;
|
|
52
|
+
return intl.formatMessage({
|
|
53
|
+
id: \\"dI+HS6\\",
|
|
54
|
+
defaultMessage: \\"foo\\"
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
case 2:
|
|
58
|
+
case \\"end\\":
|
|
59
|
+
return _context.stop();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}, _callee);
|
|
63
|
+
}));
|
|
64
|
+
return _error.apply(this, arguments);
|
|
65
|
+
}",
|
|
66
|
+
"data": Object {
|
|
67
|
+
"messages": Array [
|
|
68
|
+
Object {
|
|
69
|
+
"defaultMessage": "foo",
|
|
70
|
+
"description": "foo",
|
|
71
|
+
"id": "dI+HS6",
|
|
72
|
+
},
|
|
73
|
+
Object {
|
|
74
|
+
"defaultMessage": "foo",
|
|
75
|
+
"description": undefined,
|
|
76
|
+
"id": "dI+HS6",
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
"meta": Object {},
|
|
80
|
+
},
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
|
|
84
|
+
exports[`additionalComponentNames 1`] = `
|
|
85
|
+
Object {
|
|
86
|
+
"code": "import React, { Component } from 'react';
|
|
87
|
+
|
|
88
|
+
function CustomMessage() {}
|
|
89
|
+
|
|
90
|
+
export default class Foo extends Component {
|
|
91
|
+
render() {
|
|
92
|
+
return /*#__PURE__*/React.createElement(CustomMessage, {
|
|
93
|
+
id: \\"greeting-world\\",
|
|
94
|
+
defaultMessage: \\"Hello World!\\"
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
}",
|
|
99
|
+
"data": Object {
|
|
100
|
+
"messages": Array [
|
|
101
|
+
Object {
|
|
102
|
+
"defaultMessage": "Hello World!",
|
|
103
|
+
"description": "Greeting to the world",
|
|
104
|
+
"id": "greeting-world",
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
"meta": Object {},
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
`;
|
|
111
|
+
|
|
112
|
+
exports[`additionalFunctionNames 1`] = `
|
|
113
|
+
Object {
|
|
114
|
+
"code": "// @react-intl project:foo
|
|
115
|
+
import React, { Component } from 'react';
|
|
116
|
+
|
|
117
|
+
function CustomMessage() {}
|
|
118
|
+
|
|
119
|
+
export default class Foo extends Component {
|
|
120
|
+
render() {
|
|
121
|
+
t({
|
|
122
|
+
id: \\"mfl9RV\\",
|
|
123
|
+
defaultMessage: \\"t\\"
|
|
124
|
+
});
|
|
125
|
+
return /*#__PURE__*/React.createElement(CustomMessage, {
|
|
126
|
+
id: formatMessage({
|
|
127
|
+
id: \\"9/u6bg\\",
|
|
128
|
+
defaultMessage: \\"foo\\"
|
|
129
|
+
}),
|
|
130
|
+
description: $formatMessage({
|
|
131
|
+
id: \\"3jMyCE\\",
|
|
132
|
+
defaultMessage: \\"foo2\\"
|
|
133
|
+
}),
|
|
134
|
+
defaultMessage: \\"Hello World!\\"
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
}",
|
|
139
|
+
"data": Object {
|
|
140
|
+
"messages": Array [
|
|
141
|
+
Object {
|
|
142
|
+
"defaultMessage": "t",
|
|
143
|
+
"description": undefined,
|
|
144
|
+
"id": "mfl9RV",
|
|
145
|
+
},
|
|
146
|
+
Object {
|
|
147
|
+
"defaultMessage": "foo",
|
|
148
|
+
"description": undefined,
|
|
149
|
+
"id": "9/u6bg",
|
|
150
|
+
},
|
|
151
|
+
Object {
|
|
152
|
+
"defaultMessage": "foo2",
|
|
153
|
+
"description": undefined,
|
|
154
|
+
"id": "3jMyCE",
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
"meta": Object {
|
|
158
|
+
"project": "foo",
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
}
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
exports[`ast 1`] = `
|
|
165
|
+
Object {
|
|
166
|
+
"code": "import React, { Component } from 'react';
|
|
167
|
+
import { FormattedMessage, defineMessage, defineMessages } from 'react-intl';
|
|
168
|
+
defineMessage({
|
|
169
|
+
id: \\"defineMessage\\",
|
|
170
|
+
defaultMessage: [{
|
|
171
|
+
\\"type\\": 0,
|
|
172
|
+
\\"value\\": \\"this is a \\"
|
|
173
|
+
}, {
|
|
174
|
+
\\"type\\": 3,
|
|
175
|
+
\\"value\\": \\"dt\\",
|
|
176
|
+
\\"style\\": \\"full\\"
|
|
177
|
+
}]
|
|
178
|
+
});
|
|
179
|
+
defineMessages({
|
|
180
|
+
foo: {
|
|
181
|
+
id: \\"defineMessages1\\",
|
|
182
|
+
defaultMessage: [{
|
|
183
|
+
\\"type\\": 0,
|
|
184
|
+
\\"value\\": \\"this is a \\"
|
|
185
|
+
}, {
|
|
186
|
+
\\"type\\": 4,
|
|
187
|
+
\\"value\\": \\"dt\\",
|
|
188
|
+
\\"style\\": \\"full\\"
|
|
189
|
+
}]
|
|
190
|
+
},
|
|
191
|
+
bar: {
|
|
192
|
+
id: \\"defineMessages2\\",
|
|
193
|
+
defaultMessage: [{
|
|
194
|
+
\\"type\\": 0,
|
|
195
|
+
\\"value\\": \\"this is a \\"
|
|
196
|
+
}, {
|
|
197
|
+
\\"type\\": 2,
|
|
198
|
+
\\"value\\": \\"dt\\",
|
|
199
|
+
\\"style\\": null
|
|
200
|
+
}]
|
|
201
|
+
},
|
|
202
|
+
baz: {
|
|
203
|
+
id: 'compiled',
|
|
204
|
+
defaultMessage: [{
|
|
205
|
+
type: 0,
|
|
206
|
+
value: 'asd'
|
|
207
|
+
}]
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
export default class Foo extends Component {
|
|
211
|
+
render() {
|
|
212
|
+
Intl.formatMessage({
|
|
213
|
+
id: \\"intl.formatMessage\\",
|
|
214
|
+
defaultMessage: [{
|
|
215
|
+
\\"type\\": 0,
|
|
216
|
+
\\"value\\": \\"foo \\"
|
|
217
|
+
}, {
|
|
218
|
+
\\"type\\": 6,
|
|
219
|
+
\\"value\\": \\"s\\",
|
|
220
|
+
\\"options\\": {
|
|
221
|
+
\\"one\\": {
|
|
222
|
+
\\"value\\": [{
|
|
223
|
+
\\"type\\": 0,
|
|
224
|
+
\\"value\\": \\"1\\"
|
|
225
|
+
}]
|
|
226
|
+
},
|
|
227
|
+
\\"other\\": {
|
|
228
|
+
\\"value\\": [{
|
|
229
|
+
\\"type\\": 0,
|
|
230
|
+
\\"value\\": \\"2\\"
|
|
231
|
+
}]
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
\\"offset\\": 0,
|
|
235
|
+
\\"pluralType\\": \\"cardinal\\"
|
|
236
|
+
}]
|
|
237
|
+
});
|
|
238
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
239
|
+
id: \\"foo.bar.baz\\",
|
|
240
|
+
defaultMessage: [{
|
|
241
|
+
\\"type\\": 0,
|
|
242
|
+
\\"value\\": \\"Hello World!\\"
|
|
243
|
+
}]
|
|
244
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
245
|
+
id: \\"compiled2\\",
|
|
246
|
+
defaultMessage: [{
|
|
247
|
+
type: 0,
|
|
248
|
+
value: 'compiled comp'
|
|
249
|
+
}]
|
|
250
|
+
}));
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
}",
|
|
254
|
+
"data": Object {
|
|
255
|
+
"messages": Array [
|
|
256
|
+
Object {
|
|
257
|
+
"defaultMessage": "this is a {dt, date, full}",
|
|
258
|
+
"description": undefined,
|
|
259
|
+
"id": "defineMessage",
|
|
260
|
+
},
|
|
261
|
+
Object {
|
|
262
|
+
"defaultMessage": "this is a {dt, time, full}",
|
|
263
|
+
"description": undefined,
|
|
264
|
+
"id": "defineMessages1",
|
|
265
|
+
},
|
|
266
|
+
Object {
|
|
267
|
+
"defaultMessage": "this is a {dt, number}",
|
|
268
|
+
"description": undefined,
|
|
269
|
+
"id": "defineMessages2",
|
|
270
|
+
},
|
|
271
|
+
Object {
|
|
272
|
+
"defaultMessage": "foo {s, plural, one{1} other{2}}",
|
|
273
|
+
"description": undefined,
|
|
274
|
+
"id": "intl.formatMessage",
|
|
275
|
+
},
|
|
276
|
+
Object {
|
|
277
|
+
"defaultMessage": "Hello World!",
|
|
278
|
+
"description": "The default message.",
|
|
279
|
+
"id": "foo.bar.baz",
|
|
280
|
+
},
|
|
281
|
+
Object {
|
|
282
|
+
"defaultMessage": undefined,
|
|
283
|
+
"description": "The default message.",
|
|
284
|
+
"id": "compiled2",
|
|
285
|
+
},
|
|
286
|
+
],
|
|
287
|
+
"meta": Object {},
|
|
288
|
+
},
|
|
289
|
+
}
|
|
290
|
+
`;
|
|
291
|
+
|
|
292
|
+
exports[`defineMessage 1`] = `
|
|
293
|
+
Object {
|
|
294
|
+
"code": "// @react-intl project:amazing
|
|
295
|
+
import React, { Component } from 'react';
|
|
296
|
+
import { defineMessage, FormattedMessage } from 'react-intl';
|
|
297
|
+
var msgs = {
|
|
298
|
+
header: defineMessage({
|
|
299
|
+
id: \\"foo.bar.baz\\",
|
|
300
|
+
defaultMessage: \\"Hello World!\\"
|
|
301
|
+
}),
|
|
302
|
+
content: defineMessage({
|
|
303
|
+
id: \\"foo.bar.biff\\",
|
|
304
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
305
|
+
}),
|
|
306
|
+
kittens: defineMessage({
|
|
307
|
+
id: \\"app.home.kittens\\",
|
|
308
|
+
defaultMessage: \\"{count, plural, =0 {\\\\uD83D\\\\uDE2D} one {# kitten} other {# kittens}}\\"
|
|
309
|
+
}),
|
|
310
|
+
trailingWhitespace: defineMessage({
|
|
311
|
+
id: \\"trailing.ws\\",
|
|
312
|
+
defaultMessage: \\"Some whitespace\\"
|
|
313
|
+
}),
|
|
314
|
+
escaped: defineMessage({
|
|
315
|
+
id: \\"escaped.apostrophe\\",
|
|
316
|
+
defaultMessage: \\"A quoted value ''{value}'\\"
|
|
317
|
+
}),
|
|
318
|
+
stringKeys: defineMessage({
|
|
319
|
+
// prettier-ignore
|
|
320
|
+
'id': \\"string.key.id\\",
|
|
321
|
+
// prettier-ignore
|
|
322
|
+
'defaultMessage': \\"This is message\\"
|
|
323
|
+
})
|
|
324
|
+
};
|
|
325
|
+
export default class Foo extends Component {
|
|
326
|
+
render() {
|
|
327
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.kittens)));
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
}",
|
|
331
|
+
"data": Object {
|
|
332
|
+
"messages": Array [
|
|
333
|
+
Object {
|
|
334
|
+
"defaultMessage": "Hello World!",
|
|
335
|
+
"description": "The default message",
|
|
336
|
+
"id": "foo.bar.baz",
|
|
337
|
+
},
|
|
338
|
+
Object {
|
|
339
|
+
"defaultMessage": "Hello Nurse!",
|
|
340
|
+
"description": "Another message",
|
|
341
|
+
"id": "foo.bar.biff",
|
|
342
|
+
},
|
|
343
|
+
Object {
|
|
344
|
+
"defaultMessage": "{count, plural, =0 {😭} one {# kitten} other {# kittens}}",
|
|
345
|
+
"description": "Counts kittens",
|
|
346
|
+
"id": "app.home.kittens",
|
|
347
|
+
},
|
|
348
|
+
Object {
|
|
349
|
+
"defaultMessage": "Some whitespace",
|
|
350
|
+
"description": "Whitespace",
|
|
351
|
+
"id": "trailing.ws",
|
|
352
|
+
},
|
|
353
|
+
Object {
|
|
354
|
+
"defaultMessage": "A quoted value ''{value}'",
|
|
355
|
+
"description": "Escaped apostrophe",
|
|
356
|
+
"id": "escaped.apostrophe",
|
|
357
|
+
},
|
|
358
|
+
Object {
|
|
359
|
+
"defaultMessage": "This is message",
|
|
360
|
+
"description": "Keys as a string literal",
|
|
361
|
+
"id": "string.key.id",
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
"meta": Object {
|
|
365
|
+
"project": "amazing",
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
}
|
|
369
|
+
`;
|
|
370
|
+
|
|
371
|
+
exports[`defineMessages 1`] = `
|
|
372
|
+
Object {
|
|
373
|
+
"code": "// @react-intl project:amazing
|
|
374
|
+
import React, { Component } from 'react';
|
|
375
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
376
|
+
var msgs = defineMessages({
|
|
377
|
+
header: {
|
|
378
|
+
id: \\"foo.bar.baz\\",
|
|
379
|
+
defaultMessage: \\"Hello World!\\"
|
|
380
|
+
},
|
|
381
|
+
content: {
|
|
382
|
+
id: \\"foo.bar.biff\\",
|
|
383
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
384
|
+
},
|
|
385
|
+
kittens: {
|
|
386
|
+
id: \\"app.home.kittens\\",
|
|
387
|
+
defaultMessage: \\"{count, plural, =0 {\\\\uD83D\\\\uDE2D} one {# kitten} other {# kittens}}\\"
|
|
388
|
+
},
|
|
389
|
+
trailingWhitespace: {
|
|
390
|
+
id: \\"trailing.ws\\",
|
|
391
|
+
defaultMessage: \\"Some whitespace\\"
|
|
392
|
+
},
|
|
393
|
+
escaped: {
|
|
394
|
+
id: \\"escaped.apostrophe\\",
|
|
395
|
+
defaultMessage: \\"A quoted value ''{value}'\\"
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
export default class Foo extends Component {
|
|
399
|
+
render() {
|
|
400
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.kittens)));
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
}",
|
|
404
|
+
"data": Object {
|
|
405
|
+
"messages": Array [
|
|
406
|
+
Object {
|
|
407
|
+
"defaultMessage": "Hello World!",
|
|
408
|
+
"description": "The default message",
|
|
409
|
+
"id": "foo.bar.baz",
|
|
410
|
+
},
|
|
411
|
+
Object {
|
|
412
|
+
"defaultMessage": "Hello Nurse!",
|
|
413
|
+
"description": "Another message",
|
|
414
|
+
"id": "foo.bar.biff",
|
|
415
|
+
},
|
|
416
|
+
Object {
|
|
417
|
+
"defaultMessage": "{count, plural, =0 {😭} one {# kitten} other {# kittens}}",
|
|
418
|
+
"description": "Counts kittens",
|
|
419
|
+
"id": "app.home.kittens",
|
|
420
|
+
},
|
|
421
|
+
Object {
|
|
422
|
+
"defaultMessage": "Some whitespace",
|
|
423
|
+
"description": "Whitespace",
|
|
424
|
+
"id": "trailing.ws",
|
|
425
|
+
},
|
|
426
|
+
Object {
|
|
427
|
+
"defaultMessage": "A quoted value ''{value}'",
|
|
428
|
+
"description": "Escaped apostrophe",
|
|
429
|
+
"id": "escaped.apostrophe",
|
|
430
|
+
},
|
|
431
|
+
],
|
|
432
|
+
"meta": Object {
|
|
433
|
+
"project": "amazing",
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
}
|
|
437
|
+
`;
|
|
438
|
+
|
|
439
|
+
exports[`descriptionsAsObjects 1`] = `
|
|
440
|
+
Object {
|
|
441
|
+
"code": "import React, { Component } from 'react';
|
|
442
|
+
import { FormattedMessage } from 'react-intl'; // @react-intl project:amazing2
|
|
443
|
+
|
|
444
|
+
export default class Foo extends Component {
|
|
445
|
+
render() {
|
|
446
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
447
|
+
id: \\"foo.bar.baz\\",
|
|
448
|
+
defaultMessage: \\"Hello World!\\"
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
}",
|
|
453
|
+
"data": Object {
|
|
454
|
+
"messages": Array [
|
|
455
|
+
Object {
|
|
456
|
+
"defaultMessage": "Hello World!",
|
|
457
|
+
"description": Object {
|
|
458
|
+
"metadata": "Additional metadata content.",
|
|
459
|
+
"text": "Something for the translator.",
|
|
460
|
+
},
|
|
461
|
+
"id": "foo.bar.baz",
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
"meta": Object {
|
|
465
|
+
"project": "amazing2",
|
|
466
|
+
},
|
|
467
|
+
},
|
|
468
|
+
}
|
|
469
|
+
`;
|
|
470
|
+
|
|
471
|
+
exports[`empty 1`] = `
|
|
472
|
+
Object {
|
|
473
|
+
"code": "import React, { Component } from 'react';
|
|
474
|
+
import { defineMessage } from 'react-intl';
|
|
475
|
+
export default class Foo extends Component {
|
|
476
|
+
render() {
|
|
477
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null);
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
}",
|
|
481
|
+
"data": Object {
|
|
482
|
+
"messages": Array [],
|
|
483
|
+
"meta": Object {},
|
|
484
|
+
},
|
|
485
|
+
}
|
|
486
|
+
`;
|
|
487
|
+
|
|
488
|
+
exports[`extractFromFormatMessageCall 1`] = `
|
|
489
|
+
Object {
|
|
490
|
+
"code": "import { FormattedMessage, injectIntl } from 'react-intl';
|
|
491
|
+
import React, { Component } from 'react';
|
|
492
|
+
var objectPointer = {
|
|
493
|
+
id: 'foo.bar.invalid',
|
|
494
|
+
defaultMessage: 'This cannot be extracted',
|
|
495
|
+
description: 'the plugin only supports inline objects'
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
class Foo extends Component {
|
|
499
|
+
render() {
|
|
500
|
+
var {
|
|
501
|
+
intl
|
|
502
|
+
} = this.props;
|
|
503
|
+
var {
|
|
504
|
+
intl: {
|
|
505
|
+
formatMessage
|
|
506
|
+
}
|
|
507
|
+
} = this.props;
|
|
508
|
+
var msgs = {
|
|
509
|
+
baz: this.props.intl.formatMessage({
|
|
510
|
+
id: \\"foo.bar.baz\\",
|
|
511
|
+
defaultMessage: \\"Hello World!\\"
|
|
512
|
+
}),
|
|
513
|
+
biff: intl.formatMessage({
|
|
514
|
+
id: \\"foo.bar.biff\\",
|
|
515
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
516
|
+
}),
|
|
517
|
+
qux: formatMessage({
|
|
518
|
+
id: \\"foo.bar.qux\\",
|
|
519
|
+
defaultMessage: \\"Hello Stranger!\\"
|
|
520
|
+
}),
|
|
521
|
+
invalid: this.props.intl.formatMessage(objectPointer)
|
|
522
|
+
};
|
|
523
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, msgs.header), /*#__PURE__*/React.createElement(\\"p\\", null, msgs.content), /*#__PURE__*/React.createElement(\\"span\\", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
524
|
+
id: \\"foo\\",
|
|
525
|
+
defaultMessage: \\"bar\\"
|
|
526
|
+
})));
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
export default injectIntl(Foo);",
|
|
532
|
+
"data": Object {
|
|
533
|
+
"messages": Array [
|
|
534
|
+
Object {
|
|
535
|
+
"defaultMessage": "Hello World!",
|
|
536
|
+
"description": "The default message",
|
|
537
|
+
"id": "foo.bar.baz",
|
|
538
|
+
},
|
|
539
|
+
Object {
|
|
540
|
+
"defaultMessage": "Hello Nurse!",
|
|
541
|
+
"description": "Another message",
|
|
542
|
+
"id": "foo.bar.biff",
|
|
543
|
+
},
|
|
544
|
+
Object {
|
|
545
|
+
"defaultMessage": "Hello Stranger!",
|
|
546
|
+
"description": "A different message",
|
|
547
|
+
"id": "foo.bar.qux",
|
|
548
|
+
},
|
|
549
|
+
Object {
|
|
550
|
+
"defaultMessage": "bar",
|
|
551
|
+
"description": "baz",
|
|
552
|
+
"id": "foo",
|
|
553
|
+
},
|
|
554
|
+
],
|
|
555
|
+
"meta": Object {},
|
|
556
|
+
},
|
|
557
|
+
}
|
|
558
|
+
`;
|
|
559
|
+
|
|
560
|
+
exports[`extractFromFormatMessageCallStateless 1`] = `
|
|
561
|
+
Object {
|
|
562
|
+
"code": "import { FormattedMessage, injectIntl, useIntl } from 'react-intl';
|
|
563
|
+
import React from 'react';
|
|
564
|
+
|
|
565
|
+
function myFunction(param1, _ref) {
|
|
566
|
+
var {
|
|
567
|
+
formatMessage,
|
|
568
|
+
formatDate
|
|
569
|
+
} = _ref;
|
|
570
|
+
return formatMessage({
|
|
571
|
+
id: \\"inline1\\",
|
|
572
|
+
defaultMessage: \\"Hello params!\\"
|
|
573
|
+
}) + formatDate(new Date());
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
var child = myFunction(filterable, intl);
|
|
577
|
+
|
|
578
|
+
function SFC() {
|
|
579
|
+
var {
|
|
580
|
+
formatMessage
|
|
581
|
+
} = useIntl();
|
|
582
|
+
return formatMessage({
|
|
583
|
+
id: \\"hook\\",
|
|
584
|
+
defaultMessage: \\"hook <b>foo</b>\\"
|
|
585
|
+
});
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
var Foo = _ref2 => {
|
|
589
|
+
var {
|
|
590
|
+
intl: {
|
|
591
|
+
formatMessage
|
|
592
|
+
}
|
|
593
|
+
} = _ref2;
|
|
594
|
+
var msgs = {
|
|
595
|
+
qux: formatMessage({
|
|
596
|
+
id: \\"foo.bar.quux\\",
|
|
597
|
+
defaultMessage: \\"Hello <b>Stateless!</b>\\"
|
|
598
|
+
})
|
|
599
|
+
};
|
|
600
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, msgs.header), /*#__PURE__*/React.createElement(\\"p\\", null, msgs.content), /*#__PURE__*/React.createElement(\\"span\\", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
601
|
+
id: \\"foo\\",
|
|
602
|
+
defaultMessage: \\"bar\\"
|
|
603
|
+
})));
|
|
604
|
+
};
|
|
605
|
+
|
|
606
|
+
export default injectIntl(Foo);",
|
|
607
|
+
"data": Object {
|
|
608
|
+
"messages": Array [
|
|
609
|
+
Object {
|
|
610
|
+
"defaultMessage": "Hello params!",
|
|
611
|
+
"description": "A stateless message",
|
|
612
|
+
"id": "inline1",
|
|
613
|
+
},
|
|
614
|
+
Object {
|
|
615
|
+
"defaultMessage": "hook <b>foo</b>",
|
|
616
|
+
"description": "hook",
|
|
617
|
+
"id": "hook",
|
|
618
|
+
},
|
|
619
|
+
Object {
|
|
620
|
+
"defaultMessage": "Hello <b>Stateless!</b>",
|
|
621
|
+
"description": "A stateless message",
|
|
622
|
+
"id": "foo.bar.quux",
|
|
623
|
+
},
|
|
624
|
+
Object {
|
|
625
|
+
"defaultMessage": "bar",
|
|
626
|
+
"description": "baz",
|
|
627
|
+
"id": "foo",
|
|
628
|
+
},
|
|
629
|
+
],
|
|
630
|
+
"meta": Object {},
|
|
631
|
+
},
|
|
632
|
+
}
|
|
633
|
+
`;
|
|
634
|
+
|
|
635
|
+
exports[`extractSourceLocation 1`] = `
|
|
636
|
+
"import React, { Component } from 'react';
|
|
637
|
+
import { FormattedMessage } from 'react-intl';
|
|
638
|
+
export default class Foo extends Component {
|
|
639
|
+
render() {
|
|
640
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
641
|
+
id: \\"foo.bar.baz\\",
|
|
642
|
+
defaultMessage: \\"Hello World!\\"
|
|
643
|
+
});
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
}"
|
|
647
|
+
`;
|
|
648
|
+
|
|
649
|
+
exports[`extractSourceLocation 2`] = `
|
|
650
|
+
Array [
|
|
651
|
+
Object {
|
|
652
|
+
"defaultMessage": "Hello World!",
|
|
653
|
+
"description": undefined,
|
|
654
|
+
"end": Position {
|
|
655
|
+
"column": 78,
|
|
656
|
+
"index": 220,
|
|
657
|
+
"line": 6,
|
|
658
|
+
},
|
|
659
|
+
"file": Any<String>,
|
|
660
|
+
"filename": undefined,
|
|
661
|
+
"id": "foo.bar.baz",
|
|
662
|
+
"identifierName": undefined,
|
|
663
|
+
"start": Position {
|
|
664
|
+
"column": 11,
|
|
665
|
+
"index": 153,
|
|
666
|
+
"line": 6,
|
|
667
|
+
},
|
|
668
|
+
},
|
|
669
|
+
]
|
|
670
|
+
`;
|
|
671
|
+
|
|
672
|
+
exports[`extractSourceLocation 3`] = `Object {}`;
|
|
673
|
+
|
|
674
|
+
exports[`formatMessageCall 1`] = `
|
|
675
|
+
Object {
|
|
676
|
+
"code": "import React, { Component } from 'react';
|
|
677
|
+
import { injectIntl, FormattedMessage } from 'react-intl';
|
|
678
|
+
var objectPointer = {
|
|
679
|
+
id: 'foo.bar.invalid',
|
|
680
|
+
defaultMessage: 'This cannot be extracted',
|
|
681
|
+
description: 'the plugin only supports inline objects'
|
|
682
|
+
};
|
|
683
|
+
|
|
684
|
+
class Foo extends Component {
|
|
685
|
+
render() {
|
|
686
|
+
var msgs = {
|
|
687
|
+
baz: this.props.intl.formatMessage({
|
|
688
|
+
id: \\"foo.bar.baz\\",
|
|
689
|
+
defaultMessage: \\"Hello World!\\"
|
|
690
|
+
}),
|
|
691
|
+
biff: this.props.intl.formatMessage({
|
|
692
|
+
id: \\"foo.bar.biff\\",
|
|
693
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
694
|
+
}),
|
|
695
|
+
invalid: this.props.intl.formatMessage(objectPointer)
|
|
696
|
+
};
|
|
697
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, msgs.header), /*#__PURE__*/React.createElement(\\"p\\", null, msgs.content), /*#__PURE__*/React.createElement(\\"span\\", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
698
|
+
id: \\"foo\\",
|
|
699
|
+
defaultMessage: \\"bar\\"
|
|
700
|
+
})));
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export default injectIntl(Foo);",
|
|
706
|
+
"data": Object {
|
|
707
|
+
"messages": Array [
|
|
708
|
+
Object {
|
|
709
|
+
"defaultMessage": "Hello World!",
|
|
710
|
+
"description": "The default message",
|
|
711
|
+
"id": "foo.bar.baz",
|
|
712
|
+
},
|
|
713
|
+
Object {
|
|
714
|
+
"defaultMessage": "Hello Nurse!",
|
|
715
|
+
"description": "Another message",
|
|
716
|
+
"id": "foo.bar.biff",
|
|
717
|
+
},
|
|
718
|
+
Object {
|
|
719
|
+
"defaultMessage": "bar",
|
|
720
|
+
"description": "baz",
|
|
721
|
+
"id": "foo",
|
|
722
|
+
},
|
|
723
|
+
],
|
|
724
|
+
"meta": Object {},
|
|
725
|
+
},
|
|
726
|
+
}
|
|
727
|
+
`;
|
|
728
|
+
|
|
729
|
+
exports[`idInterpolationPattern 1`] = `
|
|
730
|
+
Object {
|
|
731
|
+
"code": "import React, { Component } from 'react';
|
|
732
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
733
|
+
var msgs = defineMessages({
|
|
734
|
+
header: {
|
|
735
|
+
id: \\"fixtures.idInterpolationPattern.4d1460\\",
|
|
736
|
+
defaultMessage: \\"Hello World!\\"
|
|
737
|
+
},
|
|
738
|
+
content: {
|
|
739
|
+
id: \\"foo.bar.biff\\",
|
|
740
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
741
|
+
}
|
|
742
|
+
});
|
|
743
|
+
export default class Foo extends Component {
|
|
744
|
+
render() {
|
|
745
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
746
|
+
id: \\"fixtures.idInterpolationPattern.36a8c8\\",
|
|
747
|
+
defaultMessage: \\"Hello World!\\"
|
|
748
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
749
|
+
id: \\"fixtures.idInterpolationPattern.5ce864\\",
|
|
750
|
+
defaultMessage: \\"NO ID\\"
|
|
751
|
+
}));
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
}",
|
|
755
|
+
"data": Object {
|
|
756
|
+
"messages": Array [
|
|
757
|
+
Object {
|
|
758
|
+
"defaultMessage": "Hello World!",
|
|
759
|
+
"description": "The default message",
|
|
760
|
+
"id": "fixtures.idInterpolationPattern.4d1460",
|
|
761
|
+
},
|
|
762
|
+
Object {
|
|
763
|
+
"defaultMessage": "Hello Nurse!",
|
|
764
|
+
"description": Object {
|
|
765
|
+
"metadata": "Additional metadata content.",
|
|
766
|
+
"text": "Something for the translator.",
|
|
767
|
+
},
|
|
768
|
+
"id": "foo.bar.biff",
|
|
769
|
+
},
|
|
770
|
+
Object {
|
|
771
|
+
"defaultMessage": "Hello World!",
|
|
772
|
+
"description": "Something for the translator. Another description",
|
|
773
|
+
"id": "fixtures.idInterpolationPattern.36a8c8",
|
|
774
|
+
},
|
|
775
|
+
Object {
|
|
776
|
+
"defaultMessage": "NO ID",
|
|
777
|
+
"description": "Something for the translator. Another description",
|
|
778
|
+
"id": "fixtures.idInterpolationPattern.5ce864",
|
|
779
|
+
},
|
|
780
|
+
],
|
|
781
|
+
"meta": Object {},
|
|
782
|
+
},
|
|
783
|
+
}
|
|
784
|
+
`;
|
|
785
|
+
|
|
786
|
+
exports[`idInterpolationPattern default 1`] = `
|
|
787
|
+
Object {
|
|
788
|
+
"code": "import React, { Component } from 'react';
|
|
789
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
790
|
+
var msgs = defineMessages({
|
|
791
|
+
header: {
|
|
792
|
+
id: \\"TRRgnX\\",
|
|
793
|
+
defaultMessage: \\"Hello World!\\"
|
|
794
|
+
},
|
|
795
|
+
content: {
|
|
796
|
+
id: \\"foo.bar.biff\\",
|
|
797
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
798
|
+
}
|
|
799
|
+
});
|
|
800
|
+
export default class Foo extends Component {
|
|
801
|
+
render() {
|
|
802
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
803
|
+
id: \\"NqjIBK\\",
|
|
804
|
+
defaultMessage: \\"Hello World!\\"
|
|
805
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
806
|
+
id: \\"XOhkQy\\",
|
|
807
|
+
defaultMessage: \\"NO ID\\"
|
|
808
|
+
}));
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
}",
|
|
812
|
+
"data": Object {
|
|
813
|
+
"messages": Array [
|
|
814
|
+
Object {
|
|
815
|
+
"defaultMessage": "Hello World!",
|
|
816
|
+
"description": "The default message",
|
|
817
|
+
"id": "TRRgnX",
|
|
818
|
+
},
|
|
819
|
+
Object {
|
|
820
|
+
"defaultMessage": "Hello Nurse!",
|
|
821
|
+
"description": Object {
|
|
822
|
+
"metadata": "Additional metadata content.",
|
|
823
|
+
"text": "Something for the translator.",
|
|
824
|
+
},
|
|
825
|
+
"id": "foo.bar.biff",
|
|
826
|
+
},
|
|
827
|
+
Object {
|
|
828
|
+
"defaultMessage": "Hello World!",
|
|
829
|
+
"description": "Something for the translator. Another description",
|
|
830
|
+
"id": "NqjIBK",
|
|
831
|
+
},
|
|
832
|
+
Object {
|
|
833
|
+
"defaultMessage": "NO ID",
|
|
834
|
+
"description": "Something for the translator. Another description",
|
|
835
|
+
"id": "XOhkQy",
|
|
836
|
+
},
|
|
837
|
+
],
|
|
838
|
+
"meta": Object {},
|
|
839
|
+
},
|
|
840
|
+
}
|
|
841
|
+
`;
|
|
842
|
+
|
|
843
|
+
exports[`inline 1`] = `
|
|
844
|
+
Object {
|
|
845
|
+
"code": "import React, { Component } from 'react';
|
|
846
|
+
import { FormattedMessage, defineMessage } from 'react-intl';
|
|
847
|
+
export default class Foo extends Component {
|
|
848
|
+
render() {
|
|
849
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
850
|
+
id: \\"foo.bar.baz\\",
|
|
851
|
+
defaultMessage: \\"Hello World!\\"
|
|
852
|
+
}), defineMessage({
|
|
853
|
+
id: \\"header\\",
|
|
854
|
+
defaultMessage: \\"Hello World!\\"
|
|
855
|
+
}), defineMessage({
|
|
856
|
+
id: \\"header2\\",
|
|
857
|
+
defaultMessage: \\"Hello World!\\"
|
|
858
|
+
}));
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
}",
|
|
862
|
+
"data": Object {
|
|
863
|
+
"messages": Array [
|
|
864
|
+
Object {
|
|
865
|
+
"defaultMessage": "Hello World!",
|
|
866
|
+
"description": "The default message.",
|
|
867
|
+
"id": "foo.bar.baz",
|
|
868
|
+
},
|
|
869
|
+
Object {
|
|
870
|
+
"defaultMessage": "Hello World!",
|
|
871
|
+
"description": "The default message",
|
|
872
|
+
"id": "header",
|
|
873
|
+
},
|
|
874
|
+
Object {
|
|
875
|
+
"defaultMessage": "Hello World!",
|
|
876
|
+
"description": "The default message",
|
|
877
|
+
"id": "header2",
|
|
878
|
+
},
|
|
879
|
+
],
|
|
880
|
+
"meta": Object {},
|
|
881
|
+
},
|
|
882
|
+
}
|
|
883
|
+
`;
|
|
884
|
+
|
|
885
|
+
exports[`overrideIdFn 1`] = `
|
|
886
|
+
Object {
|
|
887
|
+
"code": "import React, { Component } from 'react';
|
|
888
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
889
|
+
var msgs = defineMessages({
|
|
890
|
+
header: {
|
|
891
|
+
id: \\"overrideIdFn.js.foo.bar.baz.12.string\\",
|
|
892
|
+
defaultMessage: \\"Hello World!\\"
|
|
893
|
+
},
|
|
894
|
+
content: {
|
|
895
|
+
id: \\"overrideIdFn.js.foo.bar.biff.12.object\\",
|
|
896
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
export default class Foo extends Component {
|
|
900
|
+
render() {
|
|
901
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
902
|
+
id: \\"overrideIdFn.js.foo.bar.zoo.12.object\\",
|
|
903
|
+
defaultMessage: \\"Hello World!\\"
|
|
904
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
905
|
+
id: \\"overrideIdFn.js..5.object\\",
|
|
906
|
+
defaultMessage: \\"NO ID\\"
|
|
907
|
+
}));
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
}",
|
|
911
|
+
"data": Object {
|
|
912
|
+
"messages": Array [
|
|
913
|
+
Object {
|
|
914
|
+
"defaultMessage": "Hello World!",
|
|
915
|
+
"description": "The default message",
|
|
916
|
+
"id": "overrideIdFn.js.foo.bar.baz.12.string",
|
|
917
|
+
},
|
|
918
|
+
Object {
|
|
919
|
+
"defaultMessage": "Hello Nurse!",
|
|
920
|
+
"description": Object {
|
|
921
|
+
"metadata": "Additional metadata content.",
|
|
922
|
+
"text": "Something for the translator.",
|
|
923
|
+
},
|
|
924
|
+
"id": "overrideIdFn.js.foo.bar.biff.12.object",
|
|
925
|
+
},
|
|
926
|
+
Object {
|
|
927
|
+
"defaultMessage": "Hello World!",
|
|
928
|
+
"description": Object {
|
|
929
|
+
"metadata": "Additional metadata content.",
|
|
930
|
+
"text": "Something for the translator. Another description",
|
|
931
|
+
},
|
|
932
|
+
"id": "overrideIdFn.js.foo.bar.zoo.12.object",
|
|
933
|
+
},
|
|
934
|
+
Object {
|
|
935
|
+
"defaultMessage": "NO ID",
|
|
936
|
+
"description": Object {
|
|
937
|
+
"metadata": "Additional metadata content.",
|
|
938
|
+
"text": "Something for the translator. Another description",
|
|
939
|
+
},
|
|
940
|
+
"id": "overrideIdFn.js..5.object",
|
|
941
|
+
},
|
|
942
|
+
],
|
|
943
|
+
"meta": Object {},
|
|
944
|
+
},
|
|
945
|
+
}
|
|
946
|
+
`;
|
|
947
|
+
|
|
948
|
+
exports[`preserveWhitespace 1`] = `
|
|
949
|
+
Object {
|
|
950
|
+
"code": "// @react-intl project:amazing
|
|
951
|
+
import React, { Component } from 'react';
|
|
952
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
953
|
+
var msgs = defineMessages({
|
|
954
|
+
header: {
|
|
955
|
+
id: \\"foo.bar.baz\\",
|
|
956
|
+
defaultMessage: \\"Hello World!\\"
|
|
957
|
+
},
|
|
958
|
+
content: {
|
|
959
|
+
id: \\"foo.bar.biff\\",
|
|
960
|
+
defaultMessage: \\"Hello Nurse!\\"
|
|
961
|
+
},
|
|
962
|
+
kittens: {
|
|
963
|
+
id: \\"app.home.kittens\\",
|
|
964
|
+
defaultMessage: \\"{count, plural, =0 {\\\\uD83D\\\\uDE2D} one {# kitten} other {# kittens}}\\"
|
|
965
|
+
},
|
|
966
|
+
trailingWhitespace: {
|
|
967
|
+
id: \\"trailing.ws\\",
|
|
968
|
+
defaultMessage: \\" Some whitespace \\"
|
|
969
|
+
},
|
|
970
|
+
escaped: {
|
|
971
|
+
id: \\"escaped.apostrophe\\",
|
|
972
|
+
defaultMessage: \\"A quoted value ''{value}'\\"
|
|
973
|
+
},
|
|
974
|
+
newline: {
|
|
975
|
+
id: \\"newline\\",
|
|
976
|
+
defaultMessage: \\"this is a message\\"
|
|
977
|
+
},
|
|
978
|
+
linebreak: {
|
|
979
|
+
id: \\"linebreak\\",
|
|
980
|
+
defaultMessage: \\"this is\\\\na message\\"
|
|
981
|
+
},
|
|
982
|
+
templateLinebreak: {
|
|
983
|
+
id: \\"templateLinebreak\\",
|
|
984
|
+
defaultMessage: \\"this is\\\\n a message\\"
|
|
985
|
+
}
|
|
986
|
+
});
|
|
987
|
+
export default class Foo extends Component {
|
|
988
|
+
render() {
|
|
989
|
+
return /*#__PURE__*/React.createElement(\\"div\\", null, /*#__PURE__*/React.createElement(\\"h1\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.header)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.content)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, msgs.kittens)), /*#__PURE__*/React.createElement(\\"p\\", null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
990
|
+
id: \\"inline.linebreak\\",
|
|
991
|
+
defaultMessage: \\"formatted message with linebreak\\"
|
|
992
|
+
})));
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
}",
|
|
996
|
+
"data": Object {
|
|
997
|
+
"messages": Array [
|
|
998
|
+
Object {
|
|
999
|
+
"defaultMessage": "Hello World!",
|
|
1000
|
+
"description": "The default message",
|
|
1001
|
+
"id": "foo.bar.baz",
|
|
1002
|
+
},
|
|
1003
|
+
Object {
|
|
1004
|
+
"defaultMessage": "Hello Nurse!",
|
|
1005
|
+
"description": "Another message",
|
|
1006
|
+
"id": "foo.bar.biff",
|
|
1007
|
+
},
|
|
1008
|
+
Object {
|
|
1009
|
+
"defaultMessage": "{count, plural, =0 {😭} one {# kitten} other {# kittens}}",
|
|
1010
|
+
"description": "Counts kittens",
|
|
1011
|
+
"id": "app.home.kittens",
|
|
1012
|
+
},
|
|
1013
|
+
Object {
|
|
1014
|
+
"defaultMessage": " Some whitespace ",
|
|
1015
|
+
"description": "Whitespace",
|
|
1016
|
+
"id": "trailing.ws",
|
|
1017
|
+
},
|
|
1018
|
+
Object {
|
|
1019
|
+
"defaultMessage": "A quoted value ''{value}'",
|
|
1020
|
+
"description": "Escaped apostrophe",
|
|
1021
|
+
"id": "escaped.apostrophe",
|
|
1022
|
+
},
|
|
1023
|
+
Object {
|
|
1024
|
+
"defaultMessage": "this is a message",
|
|
1025
|
+
"description": "this is a description",
|
|
1026
|
+
"id": "newline",
|
|
1027
|
+
},
|
|
1028
|
+
Object {
|
|
1029
|
+
"defaultMessage": "this is
|
|
1030
|
+
a message",
|
|
1031
|
+
"description": "this is
|
|
1032
|
+
a
|
|
1033
|
+
description",
|
|
1034
|
+
"id": "linebreak",
|
|
1035
|
+
},
|
|
1036
|
+
Object {
|
|
1037
|
+
"defaultMessage": "this is
|
|
1038
|
+
a message",
|
|
1039
|
+
"description": "this is
|
|
1040
|
+
a
|
|
1041
|
+
description",
|
|
1042
|
+
"id": "templateLinebreak",
|
|
1043
|
+
},
|
|
1044
|
+
Object {
|
|
1045
|
+
"defaultMessage": "formatted message
|
|
1046
|
+
with linebreak",
|
|
1047
|
+
"description": "foo
|
|
1048
|
+
bar",
|
|
1049
|
+
"id": "inline.linebreak",
|
|
1050
|
+
},
|
|
1051
|
+
],
|
|
1052
|
+
"meta": Object {
|
|
1053
|
+
"project": "amazing",
|
|
1054
|
+
},
|
|
1055
|
+
},
|
|
1056
|
+
}
|
|
1057
|
+
`;
|
|
1058
|
+
|
|
1059
|
+
exports[`removeDefaultMessage + overrideIdFn 1`] = `
|
|
1060
|
+
Object {
|
|
1061
|
+
"code": "import React, { Component } from 'react';
|
|
1062
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
1063
|
+
defineMessages({
|
|
1064
|
+
foo: {
|
|
1065
|
+
id: \\"removeDefaultMessage.js.greeting-user.13.string\\"
|
|
1066
|
+
},
|
|
1067
|
+
foo2: {
|
|
1068
|
+
id: \\"removeDefaultMessage.js..8.string\\"
|
|
1069
|
+
},
|
|
1070
|
+
foo3: {
|
|
1071
|
+
id: \\"removeDefaultMessage.js..8.string\\"
|
|
1072
|
+
}
|
|
1073
|
+
});
|
|
1074
|
+
export default class Foo extends Component {
|
|
1075
|
+
render() {
|
|
1076
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1077
|
+
id: \\"removeDefaultMessage.js.greeting-world.12.string\\"
|
|
1078
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1079
|
+
id: \\"removeDefaultMessage.js..17.string\\"
|
|
1080
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1081
|
+
id: \\"removeDefaultMessage.js..12.string\\"
|
|
1082
|
+
}));
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
}",
|
|
1086
|
+
"data": Object {
|
|
1087
|
+
"messages": Array [
|
|
1088
|
+
Object {
|
|
1089
|
+
"defaultMessage": "Hello, {name}",
|
|
1090
|
+
"description": "Greeting the user",
|
|
1091
|
+
"id": "removeDefaultMessage.js.greeting-user.13.string",
|
|
1092
|
+
},
|
|
1093
|
+
Object {
|
|
1094
|
+
"defaultMessage": "foo2-msg",
|
|
1095
|
+
"description": "foo2",
|
|
1096
|
+
"id": "removeDefaultMessage.js..8.string",
|
|
1097
|
+
},
|
|
1098
|
+
Object {
|
|
1099
|
+
"defaultMessage": "foo3-msg",
|
|
1100
|
+
"description": undefined,
|
|
1101
|
+
"id": "removeDefaultMessage.js..8.string",
|
|
1102
|
+
},
|
|
1103
|
+
Object {
|
|
1104
|
+
"defaultMessage": "Hello World!",
|
|
1105
|
+
"description": "Greeting to the world",
|
|
1106
|
+
"id": "removeDefaultMessage.js.greeting-world.12.string",
|
|
1107
|
+
},
|
|
1108
|
+
Object {
|
|
1109
|
+
"defaultMessage": "message with desc",
|
|
1110
|
+
"description": "desc with desc",
|
|
1111
|
+
"id": "removeDefaultMessage.js..17.string",
|
|
1112
|
+
},
|
|
1113
|
+
Object {
|
|
1114
|
+
"defaultMessage": "message only",
|
|
1115
|
+
"description": undefined,
|
|
1116
|
+
"id": "removeDefaultMessage.js..12.string",
|
|
1117
|
+
},
|
|
1118
|
+
],
|
|
1119
|
+
"meta": Object {},
|
|
1120
|
+
},
|
|
1121
|
+
}
|
|
1122
|
+
`;
|
|
1123
|
+
|
|
1124
|
+
exports[`removeDefaultMessage 1`] = `
|
|
1125
|
+
Object {
|
|
1126
|
+
"code": "import React, { Component } from 'react';
|
|
1127
|
+
import { defineMessages, FormattedMessage } from 'react-intl';
|
|
1128
|
+
defineMessages({
|
|
1129
|
+
foo: {
|
|
1130
|
+
id: \\"greeting-user\\"
|
|
1131
|
+
},
|
|
1132
|
+
foo2: {
|
|
1133
|
+
id: \\"xoMBqZ\\"
|
|
1134
|
+
},
|
|
1135
|
+
foo3: {
|
|
1136
|
+
id: \\"s0FUZ6\\"
|
|
1137
|
+
}
|
|
1138
|
+
});
|
|
1139
|
+
export default class Foo extends Component {
|
|
1140
|
+
render() {
|
|
1141
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1142
|
+
id: \\"greeting-world\\"
|
|
1143
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1144
|
+
id: \\"mdcDCs\\"
|
|
1145
|
+
}), /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1146
|
+
id: \\"xjsqOM\\"
|
|
1147
|
+
}));
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
}",
|
|
1151
|
+
"data": Object {
|
|
1152
|
+
"messages": Array [
|
|
1153
|
+
Object {
|
|
1154
|
+
"defaultMessage": "Hello, {name}",
|
|
1155
|
+
"description": "Greeting the user",
|
|
1156
|
+
"id": "greeting-user",
|
|
1157
|
+
},
|
|
1158
|
+
Object {
|
|
1159
|
+
"defaultMessage": "foo2-msg",
|
|
1160
|
+
"description": "foo2",
|
|
1161
|
+
"id": "xoMBqZ",
|
|
1162
|
+
},
|
|
1163
|
+
Object {
|
|
1164
|
+
"defaultMessage": "foo3-msg",
|
|
1165
|
+
"description": undefined,
|
|
1166
|
+
"id": "s0FUZ6",
|
|
1167
|
+
},
|
|
1168
|
+
Object {
|
|
1169
|
+
"defaultMessage": "Hello World!",
|
|
1170
|
+
"description": "Greeting to the world",
|
|
1171
|
+
"id": "greeting-world",
|
|
1172
|
+
},
|
|
1173
|
+
Object {
|
|
1174
|
+
"defaultMessage": "message with desc",
|
|
1175
|
+
"description": "desc with desc",
|
|
1176
|
+
"id": "mdcDCs",
|
|
1177
|
+
},
|
|
1178
|
+
Object {
|
|
1179
|
+
"defaultMessage": "message only",
|
|
1180
|
+
"description": undefined,
|
|
1181
|
+
"id": "xjsqOM",
|
|
1182
|
+
},
|
|
1183
|
+
],
|
|
1184
|
+
"meta": Object {},
|
|
1185
|
+
},
|
|
1186
|
+
}
|
|
1187
|
+
`;
|
|
1188
|
+
|
|
1189
|
+
exports[`skipExtractionFormattedMessage 1`] = `
|
|
1190
|
+
Object {
|
|
1191
|
+
"code": "import React, { Component } from 'react';
|
|
1192
|
+
import { FormattedMessage } from 'react-intl';
|
|
1193
|
+
|
|
1194
|
+
function nonStaticId() {
|
|
1195
|
+
return 'baz';
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
export default class Foo extends Component {
|
|
1199
|
+
render() {
|
|
1200
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1201
|
+
id: \\"foo.bar.\\".concat(nonStaticId())
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
}",
|
|
1206
|
+
"data": Object {
|
|
1207
|
+
"messages": Array [],
|
|
1208
|
+
"meta": Object {},
|
|
1209
|
+
},
|
|
1210
|
+
}
|
|
1211
|
+
`;
|
|
1212
|
+
|
|
1213
|
+
exports[`templateLiteral 1`] = `
|
|
1214
|
+
Object {
|
|
1215
|
+
"code": "import React, { Component } from 'react';
|
|
1216
|
+
import { FormattedMessage, defineMessage } from 'react-intl';
|
|
1217
|
+
defineMessage({
|
|
1218
|
+
id: \\"template\\",
|
|
1219
|
+
defaultMessage: \\"should remove newline and extra spaces\\"
|
|
1220
|
+
});
|
|
1221
|
+
export default class Foo extends Component {
|
|
1222
|
+
render() {
|
|
1223
|
+
return /*#__PURE__*/React.createElement(FormattedMessage, {
|
|
1224
|
+
id: \\"foo.bar.baz\\",
|
|
1225
|
+
defaultMessage: \\"Hello World!\\"
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
}",
|
|
1230
|
+
"data": Object {
|
|
1231
|
+
"messages": Array [
|
|
1232
|
+
Object {
|
|
1233
|
+
"defaultMessage": "should remove newline and extra spaces",
|
|
1234
|
+
"description": undefined,
|
|
1235
|
+
"id": "template",
|
|
1236
|
+
},
|
|
1237
|
+
Object {
|
|
1238
|
+
"defaultMessage": "Hello World!",
|
|
1239
|
+
"description": "The default message.",
|
|
1240
|
+
"id": "foo.bar.baz",
|
|
1241
|
+
},
|
|
1242
|
+
],
|
|
1243
|
+
"meta": Object {},
|
|
1244
|
+
},
|
|
1245
|
+
}
|
|
1246
|
+
`;
|