|
| 1 | +// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html |
| 2 | + |
| 3 | +exports[`Deduplication: Explicit names with different attributes throw an error 1`] = ` |
| 4 | +[SyntaxError: <cwd>/<filename>jsx: Unsupported macro usage. Please check the examples at https://lingui.dev/ref/macro#examples-of-js-macros. |
| 5 | + If you think this is a bug, fill in an issue at https://github.com/lingui/js-lingui/issues |
| 6 | +
|
| 7 | + Error: Multiple distinct JSX elements with the same placeholder name (\`link\`). Differentiate them by adding/modifying the JSX attribute (e.g. \`<element _t="newName" />\`). |
| 8 | + 1 | |
| 9 | + 2 | import { Trans } from '@lingui/react/macro'; |
| 10 | +> 3 | <Trans>Hello <a _t="link" href="/a">link 1</a>, normal, <a _t="link" href="/b">link 2</a>.</Trans> |
| 11 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 12 | + 4 | |
| 13 | + 1 | |
| 14 | + 2 | import { Trans } from '@lingui/react/macro'; |
| 15 | +> 3 | <Trans>Hello <a _t="link" href="/a">link 1</a>, normal, <a _t="link" href="/b">link 2</a>.</Trans> |
| 16 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 17 | + 4 | ] |
| 18 | +`; |
| 19 | +
|
| 20 | +exports[`Deduplication: Identical elements are reused 1`] = ` |
| 21 | +import { Trans } from "@lingui/react/macro"; |
| 22 | +<Trans> |
| 23 | + Hello <em>emphasis</em>, normal, <em>more emphasis</em>. |
| 24 | +</Trans>; |
| 25 | +
|
| 26 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 27 | +
|
| 28 | +import { Trans as _Trans } from "@lingui/react"; |
| 29 | +<_Trans |
| 30 | + { |
| 31 | + /*i18n*/ |
| 32 | + ...{ |
| 33 | + id: "idxihm", |
| 34 | + message: "Hello <em>emphasis</em>, normal, <em>more emphasis</em>.", |
| 35 | + components: { |
| 36 | + em: <em />, |
| 37 | + }, |
| 38 | + } |
| 39 | + } |
| 40 | +/>; |
| 41 | +
|
| 42 | +`; |
| 43 | +
|
| 44 | +exports[`Deduplication: Identical elements with different prop order are reused 1`] = ` |
| 45 | +import { Trans } from "@lingui/react/macro"; |
| 46 | +<Trans> |
| 47 | + Hello{" "} |
| 48 | + <a _t="link" href="/a" class="foo"> |
| 49 | + link 1 |
| 50 | + </a> |
| 51 | + , normal,{" "} |
| 52 | + <a _t="link" class="foo" href="/a"> |
| 53 | + link 1 copy |
| 54 | + </a> |
| 55 | + . |
| 56 | +</Trans>; |
| 57 | +
|
| 58 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 59 | +
|
| 60 | +import { Trans as _Trans } from "@lingui/react"; |
| 61 | +<_Trans |
| 62 | + { |
| 63 | + /*i18n*/ |
| 64 | + ...{ |
| 65 | + id: "9en3MH", |
| 66 | + message: "Hello <link>link 1</link>, normal, <link>link 1 copy</link>.", |
| 67 | + components: { |
| 68 | + link: <a class="foo" href="/a" />, |
| 69 | + }, |
| 70 | + } |
| 71 | + } |
| 72 | +/>; |
| 73 | +
|
| 74 | +`; |
| 75 | +
|
| 76 | +exports[`Deduplication: Implicit names with distinct attributes throw an error 1`] = ` |
| 77 | +[SyntaxError: <cwd>/<filename>jsx: Unsupported macro usage. Please check the examples at https://lingui.dev/ref/macro#examples-of-js-macros. |
| 78 | + If you think this is a bug, fill in an issue at https://github.com/lingui/js-lingui/issues |
| 79 | +
|
| 80 | + Error: Multiple distinct JSX elements with the same placeholder name (\`a\`). Differentiate them by adding/modifying the JSX attribute (e.g. \`<element undefined="newName" />\`). |
| 81 | + 1 | |
| 82 | + 2 | import { Trans } from '@lingui/react/macro'; |
| 83 | +> 3 | <Trans>Hello <a href="/a">link 1</a>, normal, <a href="/b">link 2</a>.</Trans> |
| 84 | + | ^^^^^^^^^^^^^^^^^^^^^^^ |
| 85 | + 4 | |
| 86 | + 1 | |
| 87 | + 2 | import { Trans } from '@lingui/react/macro'; |
| 88 | +> 3 | <Trans>Hello <a href="/a">link 1</a>, normal, <a href="/b">link 2</a>.</Trans> |
| 89 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 90 | + 4 | ] |
| 91 | +`; |
| 92 | +
|
| 93 | +exports[`Deduplication: Same explicit placeholder with identical attributes does not throw 1`] = ` |
| 94 | +import { Trans } from "@lingui/react/macro"; |
| 95 | +<Trans> |
| 96 | + Hello{" "} |
| 97 | + <a _t="link" href="/a"> |
| 98 | + link 1 |
| 99 | + </a> |
| 100 | + , normal,{" "} |
| 101 | + <a _t="link" href="/a"> |
| 102 | + link 1 copy |
| 103 | + </a> |
| 104 | + . |
| 105 | +</Trans>; |
| 106 | +
|
| 107 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 108 | +
|
| 109 | +import { Trans as _Trans } from "@lingui/react"; |
| 110 | +<_Trans |
| 111 | + { |
| 112 | + /*i18n*/ |
| 113 | + ...{ |
| 114 | + id: "9en3MH", |
| 115 | + message: "Hello <link>link 1</link>, normal, <link>link 1 copy</link>.", |
| 116 | + components: { |
| 117 | + link: <a href="/a" />, |
| 118 | + }, |
| 119 | + } |
| 120 | + } |
| 121 | +/>; |
| 122 | +
|
| 123 | +`; |
| 124 | +
|
| 125 | +exports[`Mixing explicit _t together with jsxPlaceholderDefaults 1`] = ` |
| 126 | +import { Trans } from "@lingui/react/macro"; |
| 127 | +<Trans> |
| 128 | + Hello <a href="/a">link 1</a>, normal,{" "} |
| 129 | + <a _t="link2" href="/b"> |
| 130 | + link 2 |
| 131 | + </a> |
| 132 | + . |
| 133 | +</Trans>; |
| 134 | +
|
| 135 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 136 | +
|
| 137 | +import { Trans as _Trans } from "@lingui/react"; |
| 138 | +<_Trans |
| 139 | + { |
| 140 | + /*i18n*/ |
| 141 | + ...{ |
| 142 | + id: "yU9TUm", |
| 143 | + message: "Hello <link>link 1</link>, normal, <link2>link 2</link2>.", |
| 144 | + components: { |
| 145 | + link: <a href="/a" />, |
| 146 | + link2: <a href="/b" />, |
| 147 | + }, |
| 148 | + } |
| 149 | + } |
| 150 | +/>; |
| 151 | +
|
| 152 | +`; |
| 153 | +
|
| 154 | +exports[`Placeholder attribute is stripped from AST 1`] = ` |
| 155 | +import { Trans } from "@lingui/react/macro"; |
| 156 | +<Trans> |
| 157 | + <a _t="link" href="/about"> |
| 158 | + About |
| 159 | + </a> |
| 160 | +</Trans>; |
| 161 | +
|
| 162 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 163 | +
|
| 164 | +import { Trans as _Trans } from "@lingui/react"; |
| 165 | +<_Trans |
| 166 | + { |
| 167 | + /*i18n*/ |
| 168 | + ...{ |
| 169 | + id: "Ym2S6K", |
| 170 | + message: "<link>About</link>", |
| 171 | + components: { |
| 172 | + link: <a href="/about" />, |
| 173 | + }, |
| 174 | + } |
| 175 | + } |
| 176 | +/>; |
| 177 | +
|
| 178 | +`; |
| 179 | +
|
| 180 | +exports[`Respects jsxPlaceholderDefaults 1`] = ` |
| 181 | +import { Trans } from "@lingui/react/macro"; |
| 182 | +<Trans> |
| 183 | + Here's a <a>link</a> and <em>emphasis</em>. |
| 184 | +</Trans>; |
| 185 | +
|
| 186 | +↓ ↓ ↓ ↓ ↓ ↓ |
| 187 | +
|
| 188 | +import { Trans as _Trans } from "@lingui/react"; |
| 189 | +<_Trans |
| 190 | + { |
| 191 | + /*i18n*/ |
| 192 | + ...{ |
| 193 | + id: "Jg_WOt", |
| 194 | + message: "Here's a <link>link</link> and <em>emphasis</em>.", |
| 195 | + components: { |
| 196 | + link: <a />, |
| 197 | + em: <em />, |
| 198 | + }, |
| 199 | + } |
| 200 | + } |
| 201 | +/>; |
| 202 | +
|
| 203 | +`; |
0 commit comments