angular: localize doesn't work with target: ES2015

I’m working with angular since several years now and localization is a problem again and again. First it starts with the question, how should the ecosystem around translation look like, what’s the best practice here? There is no documentation, recommendation or help for the steps after extracting i18n. It start’s with the fact, that translations by default are not merged, so I added xliffmerge do my stack. That works pretty okay. For doing translations I use poedit which is also a pretty nice tool.

But in the end I regularly get issues broken translations, because interpolation doesn’t correctly find it self through the process or currently with this Unexpected messageParts for $localize (expected an array of strings).. This error message itself is already a pain because it’s not helpful at all, because it actually just tells you “There is something wrong with your translations, good luck finding the bad one”.

The problem for me is, that I really don’t know who to “blame”. Is angular not creating proper XLIFF files, is xliffmerge not merging them correctly or is poedit doing something wrong with my files. It’s really frustrating to work with translations when beeing confronted with such errors.

So I really hope that the angular team can spend some time to add documentation about tools that are proven to work with angular. To think about integrating xliffmerge into angular CLI and to add more helpful error messages so that broken translations can be identified easier.

P.S.: Oh and what I forgot is prettier. It also adds to the mess because messages are wrapped or spaces are added which makes creating translations also harder.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 2
  • Comments: 23 (8 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like Babel changed its output for tagged template literals: https://github.com/babel/babel/pull/12588 I’ll put together a PR to fix this.

Actually, I was hoping that you were not using ES5 😸 Generally it is better to target ES2015 and then let the CLI generate downleveled code for browsers that need it. Not sure why switching solved your problem.

@petebacondarwin thanks a lot for fixing this issue. Everything works fine now 👍

@petebacondarwin thanks for your efforts and sorry for my rant at the beginning 😅 most of the time localization works fine, it’s just if it doesn’t work it’s hard to fix 😄

adding "@babel/plugin-transform-template-literals": "7.12.1" to devDependencies temporary fixe issue, as you said @petebacondarwin its related to babel changes

Can we assume that you have target: es5 in your tsconfig.json?

@DaSchTour - I am sorry you are having difficulties around translating your projects. While I understand your frustration there is little in this issue that we can act upon. I will create a PR to provide more information when the Unexpected messageParts for $localize (expected an array of strings) error is thrown. But other than that I don’t think this issue is actionable by us.

If you wish to propose concrete feature requests or have a specific scenario that is broken, please can you create a new issue with clear instructions on how to reproduce the issue or what exactly the feature would do. Please note that we do not intend to implement translation file “merging” since there are tools that do this and we do not have the capacity in the team to support such additional tooling.