Skip to content
Snippets Groups Projects
Commit 606dec8d authored by Robin Appelman's avatar Robin Appelman
Browse files

some minor changes in the javascript translation function

also provide Array.prototype.indexOf for browser that don't support it nativale (IE)
parent 6585e830
No related branches found
No related tags found
No related merge requests found
var _l10ncache = {};
function t(app,text){ function t(app,text){
if( !( app in _l10ncache )){ if( !( app in t.cache )){
$.post( oc_webroot+'/core/ajax/translations.php', {'app': app}, function(jsondata){
_l10ncache[app] = jsondata.data; $.post( OC.filePath('core','ajax','translations.php'), {'app': app}, function(jsondata){
t.cache[app] = jsondata.data;
}); });
// Bad answer ... // Bad answer ...
if( !( app in _l10ncache )){ if( !( app in t.cache )){
_l10ncache[app] = []; t.cache[app] = [];
} }
} }
if( typeof( _l10ncache[app][text] ) !== 'undefined' ){ if( typeof( t.cache[app][text] ) !== 'undefined' ){
return _l10ncache[app][text]; return t.cache[app][text];
} }
else{ else{
return text; return text;
} }
} }
t.cache={};
OC={ OC={
webroot:oc_webroot, webroot:oc_webroot,
coreApps:['files','admin','log','search','settings'], coreApps:['files','admin','log','search','settings','core'],
linkTo:function(app,file){ linkTo:function(app,file){
return OC.filePath(app,'',file); return OC.filePath(app,'',file);
}, },
...@@ -55,3 +56,25 @@ OC={ ...@@ -55,3 +56,25 @@ OC={
$('head').append(style); $('head').append(style);
} }
} }
if (!Array.prototype.indexOf){
Array.prototype.indexOf = function(elt /*, from*/)
{
var len = this.length;
var from = Number(arguments[1]) || 0;
from = (from < 0)
? Math.ceil(from)
: Math.floor(from);
if (from < 0)
from += len;
for (; from < len; from++)
{
if (from in this &&
this[from] === elt)
return from;
}
return -1;
};
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment