Skip to content
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

fix(localize): render context of translation file parse errors #38673

Conversation

petebacondarwin
Copy link
Member

Previously the position of the error in a translation file when parsing
it was not displayed. Just the error message.

Now the position (line and column) and some context is displayed
along with the error messages.

Fixes #38377

@petebacondarwin petebacondarwin added action: review The PR is still awaiting reviews from at least one requested reviewer area: i18n target: patch This PR is targeted for the next patch release type: bug/fix and removed cla: yes labels Sep 2, 2020
@ngbot ngbot bot modified the milestone: needsTriage Sep 2, 2020
@ngbot ngbot bot added this to the needsTriage milestone Sep 2, 2020
@googlebot
Copy link

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

Previously the position of the error in a translation file when parsing
it was not displayed. Just the error message.

Now the position (line and column) and some context is displayed
along with the error messages.

Fixes angular#38377
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 for improving debugging experience 👍

/**
* Serialize the given `element` into a parsed translation using the given `serializer`.
*/
function serializeTranslationMessage(
Copy link
Contributor

Choose a reason for hiding this comment

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

The function looks similar to the one declared in packages/localize/src/tools/src/translate/translation_files/translation_parsers/serialize_translation_message.ts. I'm wondering if we can align function signatures and return errors (as well as translation) instead of passing diagnostics object?

Copy link
Member Author

Choose a reason for hiding this comment

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

I did do that originally but it is different enough that the extra work to distinguish the two made the function much more complicated than just having a separate version for this parser.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I agree with that (to have separate implementations), but I'm wondering if their type signatures can be aligned and also the code that invokes them (in one case we register errors in the diagnostics object outside of the function, in other case - inside).

Copy link
Member Author

Choose a reason for hiding this comment

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

Let me see what I can come up with...

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks Pete! FYI, I'm happy with the current version too, so if it turns out to be problematic to change it, we can proceed with the current version as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

I cleaned it up a bit. PTAL.

@AndrewKushnir AndrewKushnir added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Sep 2, 2020
@petebacondarwin petebacondarwin added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Sep 2, 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 for the updates Pete 👍

@atscott atscott closed this in 5da1934 Sep 2, 2020
atscott pushed a commit that referenced this pull request Sep 2, 2020
Previously the position of the error in a translation file when parsing
it was not displayed. Just the error message.

Now the position (line and column) and some context is displayed
along with the error messages.

Fixes #38377

PR Close #38673
@petebacondarwin petebacondarwin deleted the i18n-icu-validation-messaging branch September 3, 2020 07:22
profanis pushed a commit to profanis/angular that referenced this pull request Sep 5, 2020
…ar#38673)

Previously the position of the error in a translation file when parsing
it was not displayed. Just the error message.

Now the position (line and column) and some context is displayed
along with the error messages.

Fixes angular#38377

PR Close angular#38673
@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 Oct 4, 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 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.

i18n tool should output the line containing the error
3 participants