i18n
This commit is contained in:
@@ -5,6 +5,7 @@ function Spot(asGlobals)
|
||||
this.consts.hash_sep = '-';
|
||||
this.consts.title = 'Spotty';
|
||||
this.consts.default_page = 'project';
|
||||
//this.consts.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
|
||||
/* Initialization */
|
||||
|
||||
@@ -77,6 +78,8 @@ function Spot(asGlobals)
|
||||
})
|
||||
.done(function(oData)
|
||||
{
|
||||
if(oData.desc.substr(0, self.consts.lang_prefix.length)==self.consts.lang_prefix) oData.desc = self.lang(oData.desc.substr(5));
|
||||
|
||||
if(oData.result==self.consts.error) fOnError(oData.desc);
|
||||
else
|
||||
{
|
||||
@@ -91,6 +94,20 @@ function Spot(asGlobals)
|
||||
});
|
||||
};
|
||||
|
||||
this.lang = function(sKey, asParams) {
|
||||
asParams = asParams || [];
|
||||
if($.type(asParams) == 'string') asParams = [asParams];
|
||||
var sLang = '';
|
||||
|
||||
if(sKey in self.consts.lang) {
|
||||
sLang = self.consts.lang[sKey];
|
||||
for(i in asParams) sLang = sLang.replace('$'+i, asParams[i]);
|
||||
}
|
||||
else console.log('missing translation: '+sKey);
|
||||
|
||||
return sLang;
|
||||
};
|
||||
|
||||
/* Page Switch - Trigger & Event catching */
|
||||
|
||||
this.onHashChange = function()
|
||||
@@ -231,6 +248,11 @@ function setElem(aoAnchor, asPath, oValue)
|
||||
}
|
||||
}
|
||||
|
||||
function getTimeZoneDesc(sTimeZoneName) {
|
||||
var sCity = sTimeZoneName.split('/')[1] || '';
|
||||
return oSpot.lang('city_time', sCity);
|
||||
}
|
||||
|
||||
$.prototype.addInput = function(sType, sName, sValue)
|
||||
{
|
||||
return $(this).append($('<input>', {type: sType, name: sName, value: sValue}).data('old_value', sValue));
|
||||
|
||||
Reference in New Issue
Block a user