[errai-dev] ErraiUI and i18n

Eric Wittmann eric.wittmann at redhat.com
Wed Mar 13 12:54:29 EDT 2013


Responses also inline, snipping for readability. :)

On 03/13/2013 11:38 AM, Jonathan Fuerth wrote:
>
> Yes, Errai UI templates are included via GWT resources. I think this makes sense for translations, too. The problem with requesting them dynamically is that it we'd need another roundtrip to the server after page load before any UI can be displayed. Not a great thing to plan for, IMO.
>

I think there are solutions to this problem, though that doesn't mean I 
disagree with you.  :)  That said, if I use GWT resources I'm worried 
that *all* translations will get pulled down (even if all at once). 
That's potentially a lot of data that won't be used.  I'm not sure if 
this is true or if this is a problem even if true.

>> 2) If we don't allow data-i18n in the template, then we would need to
>> @Inject a data-field just to change the i18n key name.
>
> That sounds like it could be inconvenient. Let's try it in some "real" apps whichever way you think is best, and then revisit.

okey dokey

>> 3) Not sure how easy it will be to generate the translation report @
>> compile time - though I agree it's a great feature.
>
> It should be pretty easy as long as we can parse the language files at compile time.

Yes, I agree - exactly my point.  At runtime the template is parsed by 
the browser, which is pretty darn good at that sort of thing (and is 
also rather lax about syntax errors).  At compile time we won't have the 
browser available, so parsing will be different.  Just something I'm a 
little worried about, that's all.

Here's another question:  what do we do about Elements that contain both 
text nodes and child elements?  For example:

<div>This is something I <b>really</b> like!</div>

What i18n keys does this create in the bundle?  Possibilities are:

== Possibility #1 - each text node is an entry in the bundle ==
This_is_something_I_=This is something I
really=really
_like_= like!

== Possibility #2 - only leaf nodes get translated ==
really=really

If we go with #2 then users could override with:

<div data-i18n="my-key-name">This is something I <b>really</b> like!</div>

With a bundle that looks like:

my-key-name=This is something I <b>really</b> like!

I think I favor the latter (only leaf elements with *only* text nodes 
get auto-translated).  That probably handles the 80% case.  Then 
data-i18n can be used to override that behavior.  As I visit the DOM I 
will stop as soon as I encounter a data-i18n attribute.

-Eric


More information about the errai-dev mailing list