-
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(macro): support tagged templates in defineMessage + short alias
- Loading branch information
1 parent
3ae3c1e
commit 9b92731
Showing
11 changed files
with
251 additions
and
113 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
29 changes: 18 additions & 11 deletions
29
packages/babel-plugin-extract-messages/test/fixtures/js-with-macros.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,41 +1,48 @@ | ||
import { t, defineMessage } from "@lingui/macro" | ||
import { t, defineMessage, msg } from "@lingui/macro" | ||
|
||
t`Message` | ||
|
||
const msg = t`Message` | ||
const msg1 = t`Message` | ||
|
||
const withDescription = defineMessage({ | ||
message: 'Description', | ||
comment: "description" | ||
message: "Description", | ||
comment: "description", | ||
}) | ||
|
||
const withId = defineMessage({ | ||
id: 'ID', | ||
message: 'Message with id' | ||
id: "ID", | ||
message: "Message with id", | ||
}) | ||
|
||
const withValues = t`Values ${param}` | ||
|
||
const withTId = t({ | ||
id: "ID Some", | ||
message: "Message with id some" | ||
message: "Message with id some", | ||
}) | ||
|
||
const withTIdBacktick = t({ | ||
id: `Backtick` | ||
id: `Backtick`, | ||
}) | ||
|
||
const tWithContextA = t({ | ||
id: "Some ID", | ||
context: "Context1" | ||
context: "Context1", | ||
}) | ||
|
||
const tWithContextB = t({ | ||
id: "Some other ID", | ||
context: "Context1" | ||
context: "Context1", | ||
}) | ||
|
||
const defineMessageWithContext = defineMessage({ | ||
id: "Some ID", | ||
context: "Context2" | ||
context: "Context2", | ||
}) | ||
|
||
const defineMessageAlias = msg({ | ||
id: "Some ID", | ||
context: "Context2", | ||
}) | ||
|
||
const defineMessageAlias2 = msg`TplLiteral` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"esModuleInterop": true | ||
"esModuleInterop": true, | ||
"strict": true | ||
}, | ||
"paths": {} | ||
"paths": {}, | ||
"include": [ | ||
"./**.tsx" | ||
] | ||
} |
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
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.