-
Notifications
You must be signed in to change notification settings - Fork 879
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
Update existing XLIFF files #3514
Conversation
🦋 Changeset detectedLatest commit: b535b56 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
fc9a9e1
to
d0caccc
Compare
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.
This is fantastic, thank you for the PR! Code and test updates look great to me.
The only missing thing is a changeset file, which is how we manage releases.
If you run npx changeset add
from the root of the monorepo, then a wizard should walk you through what to do:
- You'll want to mark
@lit/localize-tools
as having apatch
bump (would usually beminor
, but we're still on major version0
). - I believe there are two changes, you could write something like this (or exactly this):
- Existing XLIFF files will be updated instead of re-generated, so additional data added by other processes (such as `state="translated"` attributes) will be preserved instead of deleted. - XLIFF `<note>` elements generated by Lit Localize will now have a `from="lit-localize"` attribute to distinguish them from other notes.
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.
Also looks like there are some test failures:
https://github.com/lit/lit/actions/runs/3655389797/jobs/6227289104
I added the changeset as suggested. Adjusted the code to make the tests work. I was sure I had run them before committing the change ( |
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.
Great work, thank you!
`lit-localize` updates existing XLIFF translations files, if available, instead of re-generating these files from scratch. Remarks about this change: All `note` elements that result from a `lit-localize` run, will receive a `from="lit-localize"` attribute (see [from](http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#from). This is necessary to identify the note we are allowed to update in a subsequent run. Other tools might have added further `note` elements. However, this also means, that any existing XLIFF files will be changed once this version of `lit-localize` is run. We could invest a lot more time into trying to preserve indentation. Other tools might reformat the whole file using tabs or five spaces or... Guessing the most probable level of indentation for new elements, based on surrounding elements, might be doable, but I hope that such an effort is not called for yet. I adjusted the existing test case, but please feel free to suggest more scenarios we need to cover. Fixes lit#1879 Fixes lit#3439
This PR was just released in |
lit-localize
updates existing XLIFF translations files, if available, instead of re-generating these files from scratch.Remarks about this change:
All
note
elements that result from alit-localize
run, will receive afrom="lit-localize"
attribute (see from. This is necessary to identify the note we are allowed to update in a subsequent run. Other tools might have added furthernote
elements. However, this also means, that any existing XLIFF files will be changed once this version oflit-localize
is run.We could invest a lot more time into trying to preserve indentation. Other tools might reformat the whole file using tabs or five spaces or... Guessing the most probable level of indentation for new elements, based on surrounding elements, might be doable, but I hope that such an effort is not called for yet.
I adjusted the existing test case, but please feel free to suggest more scenarios we need to cover.
Fixes #1879
Fixes #3439