Skip to content

Conversation

petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Mar 2, 2020

These changes should fix #35525, and should be compatible with current CLI integration code (@clydin to confirm), although the hint based approach with accompanied change to remove the need to pass diagnostics to constructors should also improve the performance and maintainability.

This should be completely backward compatible with previous versions.

FW-1888

@ngbot ngbot bot modified the milestone: Backlog Mar 2, 2020
@pullapprove pullapprove bot requested a review from mhevery March 2, 2020 11:12
@petebacondarwin petebacondarwin force-pushed the i18n-translation-file-selection branch from e7131b9 to 9dcc985 Compare March 2, 2020 13:59
Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

LGTM, But I am not sure if I am the best person to review, as I am not familiar with the codebase. I did not see anything which would jump out at me.

@petebacondarwin petebacondarwin force-pushed the i18n-translation-file-selection branch from d5af5ed to 950ec6b Compare March 5, 2020 20:04
@petebacondarwin petebacondarwin added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker and removed PR target: TBD labels Mar 5, 2020
Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @petebacondarwin! 👍

@AndrewKushnir
Copy link
Contributor

@petebacondarwin quick question: when can we remove deprecated APIs (after the corresponding release on CLI side)? Could you please create a ticket on that, so that we clean them up when possible? Thank you.

@petebacondarwin
Copy link
Contributor Author

petebacondarwin commented Mar 7, 2020

@AndrewKushnir - regarding the deprecated overload. Since this is not actually a public API it does not have to follow our official deprecation rules. I just added the deprecation tag to remind the CLI to change their implementation. Once they have done so, we should be able to safely remove this overload. Tracking at FW-1979

This modifies the internal (but shared with CLI) API for loading/parsing
translation files. Now the parsers will return a new `Diagnostics` object
along with any translations and locale extracted from the file.

It is up to the caller to decide what to do about this, if there are errors
it is suggested that an error is thrown, which is what the `TranslationLoader`
class does.
This enables complex work to be done in `TranslationParser.canParse()`
without duplicating the work in `TranslationParser.parse()`.
…files

Previously, the `Xliff1TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="1.2">` which is the minimal requirement for such files.
…files

Previously, the `Xliff2TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="2.0">` which is the minimal requirement for such files.
This commit improves the `canParse()` method to check that the file is
valid XML and has the expected root node. Previously it was relying upon
a regular expression to do this.
@petebacondarwin petebacondarwin force-pushed the i18n-translation-file-selection branch from 950ec6b to 4f2df99 Compare March 8, 2020 14:28
matsko pushed a commit that referenced this pull request Mar 9, 2020
…5793)

This modifies the internal (but shared with CLI) API for loading/parsing
translation files. Now the parsers will return a new `Diagnostics` object
along with any translations and locale extracted from the file.

It is up to the caller to decide what to do about this, if there are errors
it is suggested that an error is thrown, which is what the `TranslationLoader`
class does.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
This enables complex work to be done in `TranslationParser.canParse()`
without duplicating the work in `TranslationParser.parse()`.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…files (#35793)

Previously, the `Xliff1TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="1.2">` which is the minimal requirement for such files.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…files (#35793)

Previously, the `Xliff2TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="2.0">` which is the minimal requirement for such files.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…35793)

This commit improves the `canParse()` method to check that the file is
valid XML and has the expected root node. Previously it was relying upon
a regular expression to do this.

PR Close #35793
@matsko matsko closed this in d88b237 Mar 9, 2020
matsko pushed a commit that referenced this pull request Mar 9, 2020
This enables complex work to be done in `TranslationParser.canParse()`
without duplicating the work in `TranslationParser.parse()`.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…files (#35793)

Previously, the `Xliff1TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="1.2">` which is the minimal requirement for such files.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…files (#35793)

Previously, the `Xliff2TranslationParser` only matched files that had a narrow
choice of extensions (e.g. `xlf`) and also relied upon a regular expression
match of an optional XML namespace directive.

This commit relaxes the requirement on both of these and, instead, relies
upon parsing the file into XML and identifying an element of the form
`<xliff version="2.0">` which is the minimal requirement for such files.

PR Close #35793
matsko pushed a commit that referenced this pull request Mar 9, 2020
…35793)

This commit improves the `canParse()` method to check that the file is
valid XML and has the expected root node. Previously it was relying upon
a regular expression to do this.

PR Close #35793
@petebacondarwin petebacondarwin deleted the i18n-translation-file-selection branch March 9, 2020 16:15
@angular-automatic-lock-bot
Copy link

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 Apr 9, 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 effort2: days risk: medium 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.

Update Angular 8 to 9 problem with angular.json translation file format
5 participants