standard i18n mechanism for inline html?

View: New views
1 Messages — Rating Filter:   Alert me  

standard i18n mechanism for inline html?

by Bryan Berry-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Working on the Karma Project, I have stumbled into a gray area for
internationalization. The Karma project aims to create learning software
or "lessons" that can run in the browser, online or offline w/out server
emulation, using only openweb technologies.

The gray area is how to translate text strings inline with HTML.

For example:

<p> Translate <strong>me</strong>!</p>

Doing this with ruby on rails or django, you would use a server-side
template that puts code inline with the markup:

<p>_(Translate <strong>me</strong>!)</p>

This approach works well but couples the code to a particular
server-side implementation. In my particular use case, I am creating
lessons for schoolchildren in Nepal that will be infrequently connected
to the Internet.

I could use something like Google Gears to simulate as server-side
gettext mechanism but that would again tie me to a specific plugin.

My current intent is to use the data-* html5 attributes for marking
strings for translation. The data-* attributes can be manipulated by
users without causing rendering problems. I think that "data-_" used as
a flag to mark strings for translation.

For those unfamiliar with GNU gettext, "_" is used as shortcut for the
gettext("string") command

My example:

<p data-_> Translate <strong>me</strong>!</p>

I will write a custom script to print out all inline html marked as such
to a .pot file or translation template file. Note that "Translate
<strong>me</strong>!" will be written to the .pot file, not just the
text as placement of the <strong> tag could vary per target locale.

On page load, I will have to run pre-processing script to change out
strings on all tags marked with the data-_ flag. This could be slow but
I don't have a better idea. If performance is really an issue, I could
do the translation offline to separate html pages like index_es-SP.html,
index_pt-BR.html

One excellent thing about using data-* attributes is that I can extend
them to accommodate additional features of GNU Gettext such as comments
to clarify word usage.

Example:

<button data-_ data-_comment="request for obedience">submit</button>

I would very much appreciate comments from the OpenWeb community and
welcome superior ideas.

I have cc'd the svg-developers list because I would love to know if a
similar method could be used w/ svg


--
Bryan W. Berry
Senior Engineer
OLE Nepal, http://www.olenepal.org