zewa666 / aurelia-i18next

An Aurelia-Wrapper for the i18next library
MIT License
17 stars 15 forks source link

Use attributes to manage translations #11

Closed wichert closed 9 years ago

wichert commented 9 years ago

The current way to do translations with aurelia-i18n looks like this:

<p>${ 'message' | t}</p>

You then need to run a tool like i18next-parser over your templates to produce a JSON file, enter the canonical text in there and then pass that on to translators. There are several things I personally do not like about this approach:

An alternative approach to managing translations in a HTML context is to use attributes to mark elements as translatable. One way of doing this is the zope.i18n syntax. I made a quick gist which shows what this looks like. A few notes about this example:

The zope.i18n approach works quite well. I won't argue that it is perfect, there is certainly some room for improvement:

Obviel has an implementation of a zope.i18n-inspired syntax that is also interesting to look at.

zewa666 commented 9 years ago

Haven't had yet time to take a closer look at it but at least for two of the points there are solutions already present:

  1. Non-standard magic naming Honestly I don't know what a standard would be or who would define that. POT? Anyways i18n allows you easily to define your own prefix/suffix. Take a look at those tests: https://github.com/zewa666/aurelia-i18next/blob/master/test/unit/feature.placeholders.spec.js
  2. Nested translations Those work as well, added a new unit test for it: https://github.com/zewa666/aurelia-i18next/blob/master/test/unit/i18n.spec.js#L80-L82
Aaike commented 9 years ago

And here is a gulp task that works to extract keys and default values from the sources files to generates translation .json files. gooy/aurelia-i18next-parser

zewa666 commented 9 years ago

I'll leave this issue open while we test the heck out of it and to track any additional issues related to this. @wichert your help would be greatly appreciated

wichert commented 9 years ago

I’m fighting a few deadlines today, but I’ll definitely look at this ticket and your work again over the weekend!