Skip to content

Commit

Permalink
fix(babel-plugin-react-intl): idInterpolationPattern (#2311)
Browse files Browse the repository at this point in the history
  • Loading branch information
johakr committed Nov 15, 2020
1 parent b21641f commit 2cb1249
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/babel-plugin-react-intl/index.ts
Expand Up @@ -207,7 +207,7 @@ function evaluateMessageDescriptor(
id = overrideIdFn(id, defaultMessage, description, filename);
} else if (!id && idInterpolationPattern && defaultMessage) {
id = interpolateName(
{sourcePath: filename} as any,
{resourcePath: filename} as any,
idInterpolationPattern,
{
content: description
Expand Down
Expand Up @@ -591,7 +591,7 @@ Object {
import { defineMessages, FormattedMessage } from 'react-intl';
const msgs = defineMessages({
header: {
\\"id\\": \\"4d1460\\",
\\"id\\": \\"idInterpolationPattern.actual.4d1460\\",
\\"defaultMessage\\": \\"Hello World!\\"
},
content: {
Expand All @@ -608,8 +608,8 @@ export default class Foo extends Component {
<p>
<FormattedMessage {...msgs.content} />
</p>
<FormattedMessage id=\\"36a8c8\\" defaultMessage=\\"Hello World!\\" />
<FormattedMessage id=\\"5ce864\\" defaultMessage=\\"NO ID\\" />
<FormattedMessage id=\\"idInterpolationPattern.actual.36a8c8\\" defaultMessage=\\"Hello World!\\" />
<FormattedMessage id=\\"idInterpolationPattern.actual.5ce864\\" defaultMessage=\\"NO ID\\" />
</div>;
}
Expand All @@ -619,7 +619,7 @@ export default class Foo extends Component {
Object {
"defaultMessage": "Hello World!",
"description": "The default message",
"id": "4d1460",
"id": "idInterpolationPattern.actual.4d1460",
},
Object {
"defaultMessage": "Hello Nurse!",
Expand All @@ -632,12 +632,12 @@ export default class Foo extends Component {
Object {
"defaultMessage": "Hello World!",
"description": "Something for the translator. Another description",
"id": "36a8c8",
"id": "idInterpolationPattern.actual.36a8c8",
},
Object {
"defaultMessage": "NO ID",
"description": "Something for the translator. Another description",
"id": "5ce864",
"id": "idInterpolationPattern.actual.5ce864",
},
],
"meta": Object {},
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-react-intl/tests/index.test.ts
Expand Up @@ -26,7 +26,7 @@ const TESTS: Record<string, OptionsSchema> = {
formatMessageCall: {},
FormattedMessage: {},
idInterpolationPattern: {
idInterpolationPattern: '[sha512:contenthash:hex:6]',
idInterpolationPattern: '[folder].[name].[sha512:contenthash:hex:6]',
},
inline: {},
templateLiteral: {},
Expand Down

0 comments on commit 2cb1249

Please sign in to comment.