The Karma Project: Code Less, Teach More

July 16, 2009

Localizing Images and Audio Files

Filed under: News — bryanwb @ 8:55 am

I am posting an e-mail I wrote to the Sugar Developers list in order to bring my questions to the attention to even more people that are smarter than myself. And those sugar developers are pretty smart!

I need your thoughts on the matter of localizing audio files and image
files for Karma.

I have two strategies in mind:

1) Integrate w/ pootle
2) Not integrated w/ pootle

1) Integrate w/ pootle.

When I grab the translatable strings from my files I also grab the
filenames of the audio and image files and stick the value of the src=””
attribute into in the .po as the msgid
for example:

>> index.html
<img src=”./images/house.png”> </img>

<audio src=”./sounds/yes.ogg”> </audio>

>> karma.pot

msgid “./images/house.png”
msgstr “”

msgid “./sounds/yes.ogg”
msgstr “”

>> ne-NP.po

msgid “./images/house.png”
msgstr “./images/ne-NP_house.png”

msgid “./sounds/yes.ogg”
msgstr “./sounds/ne-NP_yes.ogg”

>> es-SP.po

msgid “./images/house.png”
msgstr “./images/es-SP_house.png”

msgid “./sounds/yes.ogg”
msgstr “./sounds/es-SP_yes.ogg”

Then to load the localized strings, I simply use a jQuery CSS selector
to write the translated strings into the markup at page load.

the code is basically:

var localeStrings = load(‘pofile_converted_to.json’);

for (var msgid in localeStrings){
//if an element matches the msgid, replace it with the msgstr
if (msgid.tagName === img or audio){
$(:contains(msgid)).attr(‘src’, localeStrings[msgid]);
else {

Using the .po file for everything that can be localized makes everything
nice and consistent

That said, the whole point of putting stuff in .po files is that u can
input the translated value directly into the .po with a text editor or
the pootle interface. Going to all this trouble when pootle doesn’t let
u upload audio and image files seems a bit of a waste.

2) Orrr, I could just check for images and sounds that are prefixed w/
the current locale at run-time and load them.

The problem with this it doesn’t give us any forward-compatibility if we
get pootle or find another solution to support crowd-sourcing
translation of audio and image assets.

Thoughts and advice are most appreciated.


1 Comment »

  1. I bet the first option.

    It would be sad not to use karma because it’s not compatible with future pootle.

    Comment by subzero — July 20, 2009 @ 7:00 pm

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

Create a free website or blog at

%d bloggers like this: