var localizedStrings={};
var getLocalizedString=function(key)
{
return localizedStrings[key] || key;
}
var getLanguageStrings=function(lang, callback)
{
var request=new XMLHttpRequest();
request.onload=function()
{
var strings=this.responseXML.getElementsByTagName('uistring'), pointer=null, i=0;
localizedStrings={};
for( ; pointer=strings[i]; i++)
{
localizedStrings[pointer.getAttribute('name')]=pointer.firstChild.nodeValue;
}
callback();
}
request.open('GET', 'home.xml');
request.send(null);
}
var setLanguageStrings=function()
{
var all=document.body.getElementsByTagName('*'), pointer=null, i=0, textContent='';
for( ; pointer=all[i]; i++)
{
if(pointer.getAttribute('lang_string'))
{
if ( pointer.firstChild && pointer.firstChild.nodeType == Node.TEXT_NODE) {
pointer.firstChild.nodeValue = getLocalizedString(pointer.firstChild.nodeValue)
} else if (pointer.value) {
pointer.value = getLocalizedString(pointer.value);
}
}
}
}
