JavaScript i18n String object & localize method

String.prototype.localize = function(){
var cReturnValue = (i18n) ? i18n[this] : this;

if(!cReturnValue){
cReturnValue = "§§§" + this + "§§§";
} else {
for (var i = 0; i < arguments.length; i++){
cReturnValue = cReturnValue.replace("{" + i + "}", arguments[i]);
}
}
return cReturnValue;
};

source

Leave a Reply