-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support extracting from all forms of i18n._ / i18n.t calls (#1586)
* feat: support extracting from all forms of i18n._ / i18n.t calls * docs(): add message extraction documentation * docs(): add experimental extractor docs
- Loading branch information
1 parent
6d645de
commit 1a0d88d
Showing
19 changed files
with
454 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 20 additions & 6 deletions
26
packages/babel-plugin-extract-messages/test/fixtures/js-call-expression.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,26 @@ | ||
const msg = i18n._("Message") | ||
|
||
const msg = i18n._('Message') | ||
const withDescription = i18n._("Description", {}, { comment: "description" }) | ||
|
||
const withDescription = i18n._('Description', {}, { comment: "description"}); | ||
const withId = i18n._("ID", {}, { message: "Message with id" }) | ||
|
||
const withId = i18n._('ID', {}, { message: 'Message with id' }); | ||
const withValues = i18n._("Values {param}", { param: param }) | ||
|
||
const withValues = i18n._('Values {param}', { param: param }); | ||
const withContext = i18n._("Some id", {}, { context: "Context1" }) | ||
|
||
const withContext = i18n._('Some id', {},{ context: 'Context1'}); | ||
// from message descriptor | ||
i18n._({ | ||
id: "my.id", | ||
message: "My Id Message", | ||
comment: "My comment", | ||
}) | ||
|
||
const withTMessageDescriptor = i18n.t({ id: 'my.id', message: 'My Id Message', comment: 'My comment'}); | ||
// support alias | ||
i18n.t("Aliased Message") | ||
|
||
// from message descriptor | ||
i18n.t({ | ||
id: "my.id", | ||
message: "My Id Message", | ||
comment: "My comment", | ||
}) |
3 changes: 0 additions & 3 deletions
3
packages/babel-plugin-extract-messages/test/fixtures/node-call-expression-aliased.js
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
packages/babel-plugin-extract-messages/test/fixtures/two-imports-renaming-esbuild.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.