Closed wichert closed 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:
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
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
I’m fighting a few deadlines today, but I’ll definitely look at this ticket and your work again over the weekend!
The current way to do translations with aurelia-i18n looks like this:
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:
header_intro_welcome
without any extra context is quite difficult.__variable__
instead of a more common syntax like${variable}
or just$variable
<p>Hello <em>${name}</em></p>
. It is not uncommon to have translations that are nested 2 (and sometimes even 3) levels deep.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:
h1
element itself as identifier.span
is marked with ani18n:name
attribute which is used in place of the element in the text seen by translators, as you can see on line 26 of the POT file. This allows the translator to move the span around in the translation as needed.i18n:translate
attribute. An extraction tool will normally add the canonical text as a comment to the message, as you can see on line 35 of the POT file.The zope.i18n approach works quite well. I won't argue that it is perfect, there is certainly some room for improvement:
i18n:translate
attribute to every element can become a bit repetitive. Genshi experimented with an alternative syntax and implicitly making all text translatable. I'm not entirely convinced that approach is better, but it is certainly interesting.Obviel has an implementation of a zope.i18n-inspired syntax that is also interesting to look at.