- The Book of Dojo
- Quick Installation
- Hello World
- Debugging Tutorial
- Introduction
- Part 1: Life With Dojo
- Part 2: Dijit
- Part 3: JavaScript With Dojo and Dijit
- Functions Used Everywhere
- Object Orientation
- Modules
- Creating and Scripting Widgets
- Writing Your Own Widget Class
- The Event System
- XMLHttpRequest (XHR)
- Drag and Drop
- Using dojo.data
- Selecting DOM Nodes with dojo.query
- i18n
- Back Button
- Other Functions
- Part 4: Testing, Tuning and Debugging
- Part 5: DojoX
- The Dojo Book, 0.4
Creating the Dojo globalization Hello World sample application
Submitted by smoverton on Mon, 09/24/2007 - 17:28.
This section introduces the first Hello World for Dojo Globalization. This Hello World application is pure HTML plus Dojo, therefore you can access it either offline or online. Please refer to Section 2.4 for detailed steps of accessing it.
Use the following steps to create an application similar to the Hello World application for Dojo globalization:
1. Include dojo bootstrap – dojo.js, and declare the locales that will be used later.
2. Declare packages for later use.
dojo.require("dojo.date.locale");
dojo.require("dojo.string");
……
3. Register a resource bundle module for the hello world application.
dojo.registerModulePath("my.helloworld","../../helloWorldResource");
4. Actions to take when you switch locales:
- Set global dojo locale.
dojo.locale = lastIndexOf("locale=") >= 0 ?
substring(lastIndexOf("locale=") + "locale=".length) : "en-us"; // default locale is en-us
- Load JSON resource bundle for hello world.
dojo.requireLocalization("my.helloworld", "helloworld");
resourceBundle = dojo.i18n.getLocalization("my.helloworld", "helloworld");
- Format date using dojo.date.locale api, and format template strings using dojo.string api.
dojo.string.substitute(resourceBundle.contentStr,
[dojo.date.locale.format(new Date(), {selector:'date', formatLength:'long'})]);
- Update UI.
dojo.byId('content').innerHTML = ……
- Printer-friendly version
- Login or register to post comments
- Subscribe post