Posted By

alvaroisorna on 12/05/07


Tagged

javascript String i18n localize


Versions (?)

JavaScript i18n String object & localize method


 / Published in: JavaScript
 

URL: http://kaedatorum.net/blog

This snippet extends the String object so that you can localize() i18n strings

  1. String.prototype.localize = function(){
  2. var cReturnValue = (i18n) ? i18n[this] : this;
  3.  
  4. if(!cReturnValue){
  5. cReturnValue = "§§§" + this + "§§§";
  6. } else {
  7. for (var i = 0; i < arguments.length; i++){
  8. cReturnValue = cReturnValue.replace("{" + i + "}", arguments[i]);
  9. }
  10. }
  11. return cReturnValue;
  12. };

Report this snippet  

You need to login to post a comment.