Re: standard i18n mechanism for inline html?

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

Parent Message unknown Re: standard i18n mechanism for inline html?

by Bryan Berry-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mike, tks for your excellent suggestions. My comments are inline

On Thu, 2009-10-29 at 16:33 -0700, Mike Samuel wrote:
>   Results {0} of {1}
> which allows for translation which change the order of substitutions.

My solution would be grab the entire string "Results 0 of 1" and leave
it to translators to rearrange. Anything truly dynamic will be generated
by javascript code, where I will output a localized string or numerical
digit using a separate function.

> I've seen similar schemes used with HTML, where
>     Tip: You can change your timezone and other <a
> href="settings#tz">settings</a>.
> is produced by the substitution string
>     Tip: You can change your timezone and other {0}settings{1}.

I don't quite understand your tip here. can you elaborate?

> You need to be careful to normalize HTML special characters in the
> translation string, and sanity check the relative order of start and
> end tag substitutions, but contract translators seem to be able to
> deal with it.

I don't quite understand what you mean. Which special characters? do you
mean like   & ?

> > 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:
>
> So you don't need to worry about redoing styles to make them work RTL?
>  Or is Urdu used at all in Nepal -- please excuse my ignorance, but
> Nepal borders the Bangladesh side of India, right?

Nepal does border India but they write in Devnagari characters, the same
as Hindi, and read from LeftToRight.

That said, I need to support RTL locales. My first thought was to change
the dir attribute in the html to rtl <html dir=rtl>. If that doesn't
work I would do it more precisely on individual elements.

> > I could use something like Google Gears to simulate as server-side
> > gettext mechanism but that would again tie me to a specific plugin.
>
> To make sure I understand, you have an HTML page, without any server
> backend, and you want to localize it?

Yes. No server back-end at all. None whatsoever

> I'm not sure what you're trying to accomplish with marking.
> (1) You want to mark strings so that you can extract a translation
> bundle to send off to a contract translator?

Yes, I want to use it to extract a string and place it in pootle
translation system where it can be handled by volunteer translators

> (2) You want to mark strings so that you can make sure that a whole
> semantic bundle (whether a phrase or multiple sentences) is translated
> together

Yes

> (3) You want to identify markup that need to be replaced to produce a
> translated version of a page?

Yes

> Why not just use mark a string for translation by using a class?
> <p class=message>This needs to be translated</p>

Because   <p data-_> ...</p>  is

1) shorter
2) more semantically meaningful, won't lead to clashes w/ other
potential class names
3) can be extended to represent the relevant context and add comments


> Do you need to deal with short ambiguous phrases, such as the English
> word "free" which has multiple senses each that corresponds to a
> different word in most other Indo-European languages?

Yes!

> > For those unfamiliar with GNU gettext, "_" is used as shortcut for the
> > gettext("string") command
>
> I'm infamiliar with it, but I think precedent and familiar APIs count
> for a lot.

I am trying to extend the current paradigm of gettext so that it
accommodates inline html. It is perhaps the dominant API for
translations excepting whatever Microsoft uses.


> So the comment is a note to translators?  Or does it help in
> specifying the sense of the word?

it is a note to translators to help them understand usage of the word.

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


Parent Message unknown Re: standard i18n mechanism for inline html?

by Bryan Berry-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-10-29 at 17:48 -0700, Mike Samuel wrote:

> >> I've seen similar schemes used with HTML, where
> >>     Tip: You can change your timezone and other <a
> >> href="settings#tz">settings</a>.
> >> is produced by the substitution string
> >>     Tip: You can change your timezone and other {0}settings{1}.
> >
> > I don't quite understand your tip here. can you elaborate?
>
> Sorry, the tip was meant to be in a translation string, but containing
> link code generated by the program.

In that case the code generated by the program would have to be
generated by a js function on page load.

> >> You need to be careful to normalize HTML special characters in the
> >> translation string, and sanity check the relative order of start and
> >> end tag substitutions, but contract translators seem to be able to
> >> deal with it.
> >
> > I don't quite understand what you mean. Which special characters? do you
> > mean like   & ?
>
> I meant HTML special characters: <. >, &, and quotes.

good point

> That will solve some problems HTML, but it will not extend to CSS
> float and left/right absolute positioning in CSS.

ugh you're right. Any ideas besides having different css files for
different locales?


> > 1) shorter
> > 2) more semantically meaningful, won't lead to clashes w/ other
> > potential class names
>
> Where do class names enter into this scheme?

It is possible-but highly unlikely- that someone could have "data-_" as
an existing class name. More likely is that someone has a class name(s)
like data-something. making data-_ a separate tag makes it more
semantically meaningful.

Also, data-_ is for limited purposes, marking strings for translation
and retrieving strings for the specified locale.


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


Parent Message unknown Re: standard i18n mechanism for inline html?

by Bryan Berry-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-10-30 at 10:04 -0700, Mike Samuel wrote:
> Your example
>   <p data-_> Translate <strong>me</strong>!</p>
> does not use classes.
>
> Was your example supposed to be
>   <p class=data-_> Translate <strong>me</strong>!</p>

No, my example was supposed to be <p data-_> ...
without using data-_ as a class name.

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


Parent Message unknown Re: standard i18n mechanism for inline html?

by Bryan Berry-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Fri, 2009-10-30 at 13:22 -0700, Mike Samuel wrote:

> 2009/10/30 Bryan Berry <bryan@...>:
> >
> > On Fri, 2009-10-30 at 10:04 -0700, Mike Samuel wrote:
> >> Your example
> >>   <p data-_> Translate <strong>me</strong>!</p>
> >> does not use classes.
> >>
> >> Was your example supposed to be
> >>   <p class=data-_> Translate <strong>me</strong>!</p>
> >
> > No, my example was supposed to be <p data-_> ...
> > without using data-_ as a class name.
>
> Ok, I don't yet understand your proposal.
> When you say
>     2) more semantically meaningful, won't lead to clashes
>        w/ other potential class names
> what is a "class name" if not one of the runs of non-whitespace
> characters appearing in the "class" attribute value of an HTML
> element?  Is the word "other" a mistake in that sentence?

by "other" I mean css class names already in use in the webapp. I am
assuming that when a webapp is first created that the developer didn't
make any initial provisions regarding i18n so my have css class names
that start w/ the prefix data

I intend to use the data-_ attribute for two purposes

1) Getting translatable strings out the document for farming out to
translators volunteer or non-volunteer. This would happen off-line in a
shell script, probably using narwhal and env.js

That script would essentially do:

pls excuse if the XPath syntax is off

$('*[@data-_]').map(function(elem){ translations.push(elem.innerHTML);})
 // then write the translations to a .po file

the functionality is the same as using $ xgettext filename   from the
command-line

2) loading translations from a .po file (translations file) at page load

$('*[@data-_]').map(function(elem){ elem.innerHTML =
translations[elem.innerHTML];})
   

>
> > --
> > Bryan W. Berry
> > Senior Engineer
> > OLE Nepal, http://www.olenepal.org
> >
> >
> > >
> >
>
> --~--~---------~--~----~------------~-------~--~----~
> Please keep in mind all of the emails on this list are publicly archived and readable, so
> don't mention anything you don't want to be public.
> All participants in this group represent themselves and not their employers.
>
> You received this message because you are subscribed to the Google
> Groups "Open Web Advocacy" group.
> To post to this group, send email to openweb-group@...
> To unsubscribe from this group, send email to
> openweb-group+unsubscribe@...
> For more options, visit this group at
> http://groups.google.com/group/openweb-group?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
--
Bryan W. Berry
Senior Engineer
OLE Nepal, http://www.olenepal.org