The Karma Project: Code Less, Teach More

September 8, 2009

i18n Options for Karma — and also HTML in the Large

Filed under: News — bryanwb @ 8:27 am

I am procrastinating learning object-oriented javascript by thinking about different i18n options for karma

Here are just a few of the key requirements for i18n in karma
1. Support inline text in the html

<div>This text should be translated</div>

2. Support in code translation
document.write(_(“This text should be translate”));

This is pretty standard use of gnu gettext and is well-supported

3. Grab inline text with inline markup

<div>This text should be captured, even the <strong>inline markup</strong> </div>

4. Whatever solution we use, it shouldn’t invalidate the html against an html5 validator, as the suggested solution for XML in GNOME would

So I only see two possible solutions at this point

1) Using a client-side micro-template, similar to a server-side template

<% this should be translated % >

advantages: could be very powerful and very flexible

drawbacks: this could be slow and could invalidate the markup. It could also make the markup hard to read. It could also cause problems accessing karma lessons from web servers that mistake the as a server-side include.

2) using the data-* collection of author-defined attributes in html5

conceivably, we could add the attribute data-k-translate=”true” to every element we want translated

advantages: doesn’t invalidate the html, makes use of html5

drawbacks: verbose,
might not be very flexible,
we would have to add the attribute to a lot of elements

We could possibly use the attribute data-k-translate-children=”true” to specify that all child elements w/ text should be translated.

Conceivably, we could also use data-k-translate-children=”false” to turn off translations for all children. I could also use

to turn off translations for the entire document.

I haven’t yet discussed i18n for the .css. In fact, I haven’t really thought hard about it. Ideas from smart folks would be much appreciated.


1 Comment »

  1. Bryan, I really like option 2. The -children feature is awesome!, really useful

    Comment by subzero — September 15, 2009 @ 3:54 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at

%d bloggers like this: