-
Notifications
You must be signed in to change notification settings - Fork 1k
[localize] Make placeholder validation pass with different expressions #4530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ba27e4c
2e6d262
362bbb3
c71665f
fb6be1c
37dba2f
ceb1001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@lit/localize-tools': patch | ||
| --- | ||
|
|
||
| Translated message validation that runs before the `build` step now disregards template literal expressions. This allow source code to have variables in expressions renamed while still keeping the same translations, or avoid errors that could happen from module import order changing which expression gets picked up first when multiple `msg()` calls with the same id have different expressions. This behavior is more consistent with how a translation unit is identified according to [how the message id is generated](https://lit.dev/docs/localization/overview/#id-generation). |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,8 +14,6 @@ e2eGoldensTest( | |
|
|
||
| Placeholder error in es-419 localization of extra-expression: unexpected "\${alert("evil")}" | ||
| Placeholder error in es-419 localization of missing-expression: missing "\${name}" | ||
| Placeholder error in es-419 localization of changed-expression: unexpected "\${alert("evil") || name}" | ||
| Placeholder error in es-419 localization of changed-expression: missing "\${name}" | ||
|
Comment on lines
-17
to
-18
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed expressions are no longer considered placeholder errors. |
||
| Placeholder error in es-419 localization of missing-html: missing "<b>" | ||
| Placeholder error in es-419 localization of missing-html: missing "</b>" | ||
| Placeholder error in es-419 localization of changed-html: unexpected "<blink>" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,9 @@ html`<Hola<b><Mundo & Amigos></b>!>`; | |
| // Expressions as attribute values should stay as expressions | ||
| html`Hello <b foo=${'World'}>World</b>`; | ||
| html`Hello <b foo=${`Mundo`}>World</b>`; | ||
| html`<b foo=${'Hello'}>Hello</b><b bar=${`Mundo`}>World</b>`; | ||
| html`<b foo=${`Hola`}>Hello</b><b bar=${`Mundo`}>World</b>`; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This diff is technically unrelated to the changes in the PR but just due to a missing translation target that I noticed from the test file. |
||
| html`Hello <b .foo=${'World'}>World</b>`; | ||
| html`Hello <b .foo=${`Mundo`}>World</b>`; | ||
| // Placeholder in translation has different expression | ||
| `${user} diferente`; | ||
| html`<b>${user}</b> diferente`; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,6 +46,18 @@ | |
| <source><Hello<ph id="0"><b></ph><World & Friends><ph id="1"></b></ph>!></source> | ||
| <target><Hola<ph id="0"><b></ph><Mundo & Amigos><ph id="1"></b></ph>!></target> | ||
| </trans-unit> | ||
| <trans-unit id="s63f0bfacf2c00f6b"> | ||
| <source>Hello</source> | ||
| <target>Hola</target> | ||
| </trans-unit> | ||
|
Comment on lines
+49
to
+52
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the missing translation target I found, mentioned above. |
||
| <trans-unit id="s372f95c2b25986c8"> | ||
| <source>Different <ph id="0">${user}</ph></source> | ||
AndrewJakubowicz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <target><ph id="0">${differentUser}</ph> diferente</target> | ||
| </trans-unit> | ||
| <trans-unit id="h5e2d21ff71e6c8b5"> | ||
| <source>Different <ph id="0"><b>${user}</b></ph></source> | ||
| <target><ph id="0"><b>${differentUser}</b></ph> diferente</target> | ||
| </trans-unit> | ||
| </body> | ||
| </file> | ||
| </xliff> | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!