[Sugar-devel] reading and writing translatable strings

Bryan Berry bryan at olenepal.org
Sun Jul 12 06:08:14 EDT 2009


this might do the trick

var mystr = "title";
$(':contains(' + mystr + '):last');

On Sun, 2009-07-12 at 15:44 +0545, Bryan Berry wrote:
> Subzero,
> 
> I have figured out how to read the strings from an html file, at least
> somewhat: 
> 
> utils/narwhal/bin/narwhal source.html output.pot
> 
> generates a .pot file from the strings in one html file
> 
> I haven't automated grabbing the strings from a .js file because it
> seems fairly straightforward.
> 
> Reading back in the strings from the po might present a problem. I
> gather that we will have to convert the po file to a .json file
> 
> I guess we can use the perl module po2json for now
> (http://jsgettext.berlios.de/doc/html/po2json.html) Later we may want to
> consider doing this w/ python or narwhal (command-line js), since
> neither u nor I know perl.
> 
> but we still have to match the strings w/ the target html.
> 
> It was dead easy to grab the strings using a css selector $('h1, h2, h3,
> title, ...') 
> 
> but to write back the strings we need to match the msgid string to the
> actual element html. Can we create a jQuery css or XPath selector that
> selects based on element html?  something like  
> 
> $('*[html="The <big>Highest</big> score is"]').   ???
> 
> I am wondering if it will be feasible performance-wise to write in all
> the strings each time the page loads. I guess the only way to find out
> is to experiment.
> 
> We could possibly pre-create localized html pages using narwhal. We
> could use the package_po.json to generate index_ne_NP.html or
> index_he.html from the command-line.
> 
> 
-- 
Bryan W. Berry
Technology Director
OLE Nepal, http://www.olenepal.org



More information about the Sugar-devel mailing list