[Sugar-devel] best way to localize audio and image files?
Bryan Berry
bryan at olenepal.org
Thu Jul 16 04:15:37 EDT 2009
Sayamindu,
I need your thoughts on the matter of localizing audio files and image
files.
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 {
$(:contains(msgid)).html(localeStrings[msgid]);
}
}
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.
Your thoughts are most appreciated.
--
Bryan W. Berry
Technology Director
OLE Nepal, http://www.olenepal.org
More information about the Sugar-devel
mailing list