-
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
[localize] Add <x equiv-text> XLIFF placeholder style and use by default #2275
Conversation
🦋 Changeset detectedLatest commit: df1fb5b The changes in this PR will be included in the next version bump. 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 |
Looks like the message ids remain the same right? |
Yep, this will have no effect on message IDs. If you upgrade and do nothing else, the next time you run |
d126198
to
1ea2454
Compare
@@ -118,7 +127,9 @@ export class XliffFormatter implements Formatter { | |||
!phText || | |||
phText.nodeType !== doc.TEXT_NODE | |||
) { | |||
throw new KnownError(`Expected <ph> to have exactly one text node`); | |||
throw new KnownError( | |||
`Expected <${child.nodeName}> to have exactly one text node` |
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.
Feel free to punt, but this seems like a good candidate for a diagnostic
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.
We're not in a TypeScript context here -- do you mean something that displays similar to how a TypeScript diagnostic displays with a text snippet and underline etc.?
@@ -0,0 +1,12 @@ | |||
/** | |||
* @license | |||
* Copyright 2020 Google LLC |
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.
Here and elsewhere: 2021
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 just a rename, so it's copyright date shouldn't change (right?). And the other new files are also clones.
@@ -0,0 +1 @@ | |||
git won't track an empty directory |
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.
(is this necessary? looks like there are files in this dir)
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.
Done
See #2271 for more context.
XLIFF is the XML format we use to represent extracted templates/strings that need translation. XLIFF specifies multiple ways of encoding placeholders (for representing HTML markup and dynamic expressions). The differences according to the spec are a bit confusing:
<ph>
: "Placeholder - The element is used to delimit a sequence of native stand-alone codes in the translation unit."<x>
: "Generic placeholder - The element is used to replace any code of the original document."Previously we were using
<ph>
, because the spec seemed to match what we need, and I was primed by XLB (Google's very similar format) which also uses<ph>
tags for this purpose. However, I found that in practice translation tools seem to have much better support for the XLIFF<x>
tag (I have tested crowdin, phrase, and lokalise). Additionally,<x>
is the approach used by Angular (see https://angular.io/guide/i18n-example), so it is likely that translation tools/services have been already tested with Angular style message extraction.This is possibly breaking because it changes the default from
<ph>
to<x>
, but upgrading both source and translated messages to<x>
will happen automatically when the user next runslit-localize extract
. We retain the ability to use<ph>
tags by setting a new config file setting.Fixes #2271
cc @fetherston fyi