nihao.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <title>Dojo Globalization Hello World</title>
  7. <script language="JavaScript" type="text/javascript">
  8. // set the global locale for Dojo from the request parameter
  9. var result = location.href.match(/[\?\&]locale=([^\&]+)/);
  10. djConfig = {locale: result && result[1] || "en-us"}; // default locale is en-us
  11. </script>
  12. <script type="text/javascript" src="../../dojo/dojo.js"></script>
  13. <style type="text/css">
  14. @import "../../dojo/resources/dojo.css";
  15. @import "../themes/tundra/tundra.css";
  16. @import "../themes/tundra/tundra_rtl.css";
  17. body {padding:1em}
  18. </style>
  19. <script language="JavaScript" type="text/javascript">
  20. dojo.require("dojo.date.locale");
  21. dojo.require("dojo.number");
  22. dojo.require("dojo.string");
  23. dojo.require("dojo.parser");
  24. dojo.require("dijit.form.DateTextBox");
  25. // load the resource bundle for HelloWorld
  26. dojo.requireLocalization("dijit.demos.nihao", "helloworld");
  27. var resourceBundle;
  28. dojo.addOnLoad(function(){
  29. // create the DateTextBox from the HTML segment with the dojoType set
  30. dojo.parser.parse();
  31. // make current locale selected
  32. dojo.byId('langList').value = dojo.locale;
  33. // get the resource bundle object of the current global locale
  34. resourceBundle = dojo.i18n.getLocalization("dijit.demos.nihao", "helloworld");
  35. // do formatting and update the resource strings
  36. dojo.byId('locale').innerHTML = resourceBundle.localeSelect;
  37. dojo.byId('content').innerHTML = dojo.string.substitute(
  38. resourceBundle.contentStr,
  39. [dojo.date.locale.format(new Date(), {selector:'date', formatLength:'long'})]);
  40. dojo.byId('date').innerHTML = resourceBundle.dateSelect;
  41. dateChanged();
  42. });
  43. function localeChanged(){
  44. open("nihao.html?locale=" + dojo.byId("langList").value, "_self");
  45. }
  46. function dateChanged(){
  47. if(resourceBundle){
  48. dojo.byId('secondsToGo').innerHTML = dojo.string.substitute(
  49. resourceBundle.dateStr,
  50. [dojo.number.format((dijit.byId("dateBox").getValue() - new Date()) / 1000)]);
  51. }
  52. }
  53. </script>
  54. </head>
  55. <body class="tundra">
  56. <h1>Dojo Globalization Hello World</h1>
  57. <p>
  58. <span id="locale"></span>
  59. <select id="langList" onchange="localeChanged();" >
  60. <option value="en-us">en-US</option>
  61. <option value="fr-fr">fr-FR</option>
  62. <option value="zh-cn">zh-CN</option>
  63. </select>
  64. </p>
  65. <hr>
  66. <p id="content"></p>
  67. <p>
  68. <span id="date"></span>
  69. <input id="dateBox" type="text" dojoType="dijit.form.DateTextBox" constraints="{formatLength:'long'}" onchange="dateChanged();">
  70. </p>
  71. <p id="secondsToGo"></p>
  72. </body>
  73. </html>