Skip to content

fix(ivy): i18n - correctly parse XLIFF placeholders - #34155

Closed
petebacondarwin wants to merge 1 commit into
angular:masterfrom
petebacondarwin:i18n-placeholders
Closed

petebacondarwin wants to merge 1 commit into
angular:masterfrom
petebacondarwin:i18n-placeholders

Conversation

@petebacondarwin

Copy link
Copy Markdown
Contributor

The ViewEngine translation extractor does not convert - to _ for
placeholders that represent custom elements. For example
<app-component> gets converted to placeholders like
START_TAG_APP-COMPONENT.

In $localize placeholders are expected to be snake-case,
not kebab-case. So we must normalize them when parsing
a translation file that might have been created via the View
Engine translation extractor.

The $localize extraction code will normalize these
placeholders when creating translation files in the first
place.

Fixes #34151

@petebacondarwin petebacondarwin added area: i18n Issues related to localization and internationalization comp: ivy state: WIP target: patch This PR is targeted for the next patch release type: bug/fix and removed cla: yes labels Nov 29, 2019
@googlebot

Copy link
Copy Markdown

☹️ Sorry, but only Googlers may change the label cla: yes.

@ngbot ngbot Bot modified the milestone: needsTriage Nov 29, 2019
@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Nov 30, 2019
The ViewEngine translation extractor does not convert `-` to `_` for
placeholders that represent custom elements. For example `<app-component>`
gets converted to placeholders like `START_TAG_APP-COMPONENT`.

In `$localize` placeholders are expected to be snake-case, not kebab-case.
So we must normalize them when parsing a translation file that might have
been created via the View Engine translation extractor.

The `$localize` extraction code will normalize these placeholders when
creating translation files in the first place.

Fixes angular#34151
@petebacondarwin
petebacondarwin marked this pull request as ready for review November 30, 2019 07:59
@petebacondarwin
petebacondarwin requested a review from a team November 30, 2019 07:59

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@AndrewKushnir AndrewKushnir removed the action: review The PR is still awaiting reviews from at least one requested reviewer label Dec 2, 2019
@petebacondarwin petebacondarwin added the action: merge The PR is ready for merge by the caretaker label Dec 2, 2019
@timofei-iatsenko

Copy link
Copy Markdown

Thanks for fixing, BTW, you wrote

the ViewEngine translation extractor does not convert - to _

Means there might be Ivy message extractor as well which should not have such problem, how to use it?

Now for non-AngularCLI project I use this snippet to extract messages from template HTML:

const {DEFAULT_INTERPOLATION_CONFIG, HtmlParser, MessageBundle, Xliff} = require('@angular/compiler');

//...
catalog.updateFromTemplate(html, relative, DEFAULT_INTERPOLATION_CONFIG);
//...

@petebacondarwin

Copy link
Copy Markdown
Contributor Author

The next-generation message extraction is still a WIP which will land after v9.0.0 - see #32912

mhevery pushed a commit that referenced this pull request Dec 2, 2019
The ViewEngine translation extractor does not convert `-` to `_` for
placeholders that represent custom elements. For example `<app-component>`
gets converted to placeholders like `START_TAG_APP-COMPONENT`.

In `$localize` placeholders are expected to be snake-case, not kebab-case.
So we must normalize them when parsing a translation file that might have
been created via the View Engine translation extractor.

The `$localize` extraction code will normalize these placeholders when
creating translation files in the first place.

Fixes #34151

PR Close #34155
@mhevery mhevery closed this in d529b55 Dec 2, 2019
@petebacondarwin
petebacondarwin deleted the i18n-placeholders branch December 2, 2019 19:39
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jan 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: i18n Issues related to localization and internationalization cla: yes target: patch This PR is targeted for the next patch release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ivy i18n Wrong placeholders generated for components with dash

4 participants