ng-extract-i18n-merge icon indicating copy to clipboard operation
ng-extract-i18n-merge copied to clipboard

Setting includeContext to false removes the context from the angular generated messages file

Open davidyoung77 opened this issue 2 years ago • 2 comments

Is your feature request related to a problem? Please describe. Setting "includeContext": false, to false removes the context from the Angular generated file

Describe the solution you'd like Merge should not touch the Angular generated file

Describe alternatives you've considered

Additional context I want to remove the location context from the merged files but leave it in the angular generated file

davidyoung77 avatar Aug 30 '22 21:08 davidyoung77

@davidyoung77 thanks for reporting in!

This behavior actually is on purpose - the assumption is that if the context is not needed for the translation, it is not needed in the original messages.xlf as well. Keeping the context in messages.xlf will (potentially) result in many changes just for line changes, that obscure the actual (textual) changes.

Could you explain your setup/situation so I can understand why you'd need to keep the context only in messages.xlf? If that applies to others as well, it should be possible to change the type of includeContext to boolean|"original_only" (or similar).

daniel-sc avatar Aug 31 '22 01:08 daniel-sc

Thanks for your quick response.

So my context is a couple points:

  • IMO this third party lib shouldn't edit the file that is generated by the Angular lib, if it needs to update the file to handle merging from, it should create a temp copy of the messages.ts file, but leave the original file untouched
  • The location context is useful for engineers and is nice in the base messages.xlf file, but provides no value to translators in the language specific files, the notes are valuable in the language specific files though

PS: I love what you have done here, and was about to write something like this myself until I stumbled on your lib. This feature should be part of the official angular lib, as it is incomplete without this.

davidyoung77 avatar Aug 31 '22 03:08 davidyoung77

@davidyoung77 I think I get your idea.

There is one point, I'm not sure you are aware of: The messages.xlf is changed by this lib for other reasons as well:

  • White space normalization (eg adding new line breaks in the template (think 'format file' in your IDE) should not lead to changes in messages.xlf as these changes are effectively meaningless and obscure the real changes in a PR.
  • Sorting of translation units. The native generation from angular-cli has a non stable order (depending on template changes). This again obscures actual changes in PR reviews.

Would these points convince you that keeping the original messages.xlf is (in most cases) not helpful? In case not: would you opt out from any changes to messages.xlf or just the removed notes?

daniel-sc avatar Sep 04 '22 03:09 daniel-sc

Thanks @daniel-sc these are good points (that I was not aware of), that sound like they should definitely be in the Angular/localize lib.

Having fewer changes in source control is a good thing.

One thing I want to make sure we are aware of is the making changes the messages.xlf file will potentially introduce complexity when supporting later versions of angular/localize, for example if they improve the way they handle ordering and normalization. This may not be a big deal, but will potentially introduce needs for supporting changes

I haven't lived with only using the angular/localize without a merging tool, as it is an incomplete lib without IMO.

Supporting includeContext to boolean|"original_only" as you suggest above, would give me what I am looking for.

davidyoung77 avatar Sep 07 '22 16:09 davidyoung77