We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


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.