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

Extract tool should write the source file name into the resource file #14190

Closed
jaska45 opened this issue Jan 30, 2017 · 11 comments · Fixed by #14705
Closed

Extract tool should write the source file name into the resource file #14190

jaska45 opened this issue Jan 30, 2017 · 11 comments · Fixed by #14705
Assignees
Labels
area: i18n feature Issue that requests a new feature

Comments

@jaska45
Copy link

jaska45 commented Jan 30, 2017

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
At the moment the extract tool generates the id values. The id value depends on the extracted string value. This means that if you change the value (e.g. fix a typo) the id gets changed. This is why our localization tool when scanning XTB or XLF does not use id attribute but the meaning attribute. We use meaning to give a unique and fixed id for each elements. Something like this

<p i18n="HeaderText|">Sample</p>
Now the extract tool gives us following

<msg id="8884523860497558714" meaning="HeaderText">Sample</msg>

The meaning value does not change unless the developer explicitly changes it. In addition the above meaning value “HeaderText” is much more informative as “8884523860497558714”.
Unfortunately it is hard to get meaning values unique among all templates.

Expected behavior
It would help a lot if the extracting tool would write the relative path name of the template file (.html or .ts) where the string comes from. Something like this

<msg id="8884523860497558714" meaning="header" source="src/app/admin/main.html">Sample</msg>

Where the source attributes contains the file name where the string comes from. Now our tool could get a unique if by combining source and meaning values. Because the meaning values would need to be unique only within the single template it would be a lot easier for the developer to maintain them.

What is the motivation / use case for changing the behavior?
To make Angular 2 localization easier and increase the translation quality

Please tell us about your environment:

  • Angular version: 2.0.X
    All

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    All

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    All

  • Node (for AoT issues): node --version =
    All

@ovidiubarbu
Copy link

I also think that this is how is supposed to work. I am hoping this feature will be implemented soon, as it'll save a lot of time to everyone!

@vicb vicb added area: i18n feature Issue that requests a new feature labels Jan 30, 2017
@vicb
Copy link
Contributor

vicb commented Jan 30, 2017

Yes this is planned - any help would be appreciated !

@chizutest
Copy link

Good idea. Thumbs up.

@daisyzhang66
Copy link

This is a great idea. I am adding one use case here. In a large project scenario, as a localization engineer, I want to know which file or template a string come from so I can communicate to a developer who owns the file or template.

@daisyzhang66
Copy link

Hi vicb, it is glad to know there is a plan in place. can you please share the timeline of the plan?

@aniketgade
Copy link

I love this idea. Hope , we see this feature implemented soon. This will definitely help better manage the strings.

@ocombe ocombe self-assigned this Feb 18, 2017
@ocombe
Copy link
Contributor

ocombe commented Feb 18, 2017

Hello, I'll start working on this one

ocombe added a commit to ocombe/angular that referenced this issue Feb 24, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 24, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 24, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 24, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 24, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 27, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 27, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 28, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 28, 2017
ocombe added a commit to ocombe/angular that referenced this issue Feb 28, 2017
ocombe added a commit to ocombe/angular that referenced this issue Mar 13, 2017
ocombe added a commit to ocombe/angular that referenced this issue Mar 13, 2017
ocombe added a commit to ocombe/angular that referenced this issue Apr 12, 2017
ocombe added a commit to ocombe/angular that referenced this issue Apr 12, 2017
ocombe added a commit to ocombe/angular that referenced this issue Apr 12, 2017
ocombe added a commit to ocombe/angular that referenced this issue Apr 12, 2017
@ocombe ocombe mentioned this issue May 2, 2017
20 tasks
@jaska45
Copy link
Author

jaska45 commented May 8, 2017

I tested it and it works. Thank you!
I have some comments:

  1. The source code elements contains an absolute path (e.g. D:/MyFiles/Project/src/app/app.component.ts:3). It think that a relative path (to the project root) would be better (e.g. src/app/app.component.ts:3)

Having absolute path makes it hard to use the values if you move the directory in another location.

  1. The source value is in an element and not in an attribute.

<msg id="4944569397970619776"><source>D:/Source/Angular/Escape/src/app/app.component.ts:2</source>Sample</msg>

What is the reason for that? Could it be in an attribute like

<msg id="4944569397970619776 source="src/app/app.component.ts:2">Sample</msg>

This would be easier to read by humans and localization tools.

  1. The translationbundle cannot contain the source element. If it exists the compilation fails. So the elemenst need to be removed. Would be nice if they could exist in the translated files.

@ocombe
Copy link
Contributor

ocombe commented May 8, 2017

good points, can you open an issue for those? especially the last one which is a bug I think
for the point 2 it's the xliff spec that is like this...

@jaska45
Copy link
Author

jaska45 commented May 8, 2017

can you open an issue for those?

Done

#16638 and #16639

@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 Sep 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: i18n feature Issue that requests a new feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants