code_junkie

Best JavaScript i18n techniques / Ajax - dates, times, numbers, currency

Nov 10th, 2011
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <script>
  2. i18n_dict = {'how old':'Ich bin %s Jahre alt'};
  3. function test_i18n(){
  4. alert($.i18n._('how old','5');
  5. }
  6. </script>
  7. <a onclick="test_i18n()">clickme</a>
  8.  
  9. <script type="text/javascript" src="../../../dojo/dojo.js"
  10. djConfig="isDebug: true, parseOnLoad: true, locale:'de'"></script>
  11.  
  12. {name: 'Column 5', field: 'col5', formatter: dojo.number.format },
  13.  
  14. <script type="text/javascript" src="jquery.i18n.properties-min.js"></script>
  15. <div class="i18n_label:foo">placeholder text</div>
  16.  
  17. i18n_label:foo=bar
  18.  
  19. $.i18n.properties({
  20. name: 'Messages',
  21. mode: 'map'
  22. });
  23.  
  24. $('[class*="i18n_label:"]').each(function(index, elem) {
  25. $(elem.classList).each(function(index, classname) {
  26. if (!classname.match(/i18n_label:/))
  27. return;
  28. var newval = $.i18n.prop(classname);
  29. if (newval)
  30. $(elem).text(newval);
  31. });
  32. });
Add Comment
Please, Sign In to add comment