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

[i18n] $localize extract translation unit & documentation #36714

Open
luchillo17 opened this issue Apr 20, 2020 · 8 comments
Open

[i18n] $localize extract translation unit & documentation #36714

luchillo17 opened this issue Apr 20, 2020 · 8 comments

Comments

@luchillo17
Copy link

@luchillo17 luchillo17 commented Apr 20, 2020

🚀 feature request

Relevant Package

This feature request is for @angular/localize

Description

Currently, the $localize API is not documented, and translation text & id is not extracted towards translation file, basically the translation units for a text translated with $localize in code have to be put in a translation unit in the file manually.

If you have many items to translate with $localize it will add load to the team, it multiplies the load by the number of locales you need to support, since each time you merge the source locale into any other locale file, with the VSCode Angular i18n plugin (and very likely with many other xlf merge utilities), those translation units you added manually will be removed and you're forced to either look into git to undo those you added by hand or add them back again.

Here's the math, if you have, say 10 items localized from code, you support 10 languages or locales, you have to re-visit 100 translation units every time you make changes that require changes in the source locale file, which is very often when you make new features or fix a typo, adding tons of load, not to mention being highly error-prone.

Describe the solution you'd like

All $localize calls are extracted into the translation file as translation units, and documentation is updated.

Describe alternatives you've considered

At the very least make the extraction work, I could take care of the docs later since I've meddled quite a bit with the $localize API for enterprise projects:

image

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Apr 20, 2020

This is being worked on #32912

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Apr 20, 2020

And $localize as an API was not made public in v9. That is why it is not yet documented. In v9 we just used it internally for template translations. The fact that you can use it in your own TS code is supposed to be a secret 🤫

@luchillo17
Copy link
Author

@luchillo17 luchillo17 commented Apr 20, 2020

🤐

@spock123
Copy link

@spock123 spock123 commented Apr 20, 2020

@petebacondarwin But it works so great... we've been able to ditch all runtime translations now, thanks to $localize .. it's wonderful

@xiaoxiangmoe
Copy link

@xiaoxiangmoe xiaoxiangmoe commented Apr 20, 2020

@petebacondarwin can we use $localize in ng-packagr in Angular 10?

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Apr 20, 2020

Once #32912 lands and we get it integrated into the CLI then I think we should be fine to use $localize.

I don't believe that ng-packagr will do anything with $localize. It should just pass them through so that the application can do the translation. This leaves us with a new interesting question of how to best support a library author providing translations for their library. I.E. can we merge translation files when translating; and/or filter out translations from libraries when extracting.

@ngbot ngbot bot modified the milestone: Backlog Apr 20, 2020
@xiaoxiangmoe
Copy link

@xiaoxiangmoe xiaoxiangmoe commented Apr 22, 2020

@petebacondarwin Should I open an issue about how to best support a library author providing translations for their library

@petebacondarwin
Copy link
Member

@petebacondarwin petebacondarwin commented Apr 22, 2020

Yes! Please do. This is something that we need to improve.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.