dojo.requireLocalization
directory within a package. Translated resources may be located in
different packages throughout the source tree. For example, a
particular widget may define one or more resource bundles,
structured in a program as follows, where moduleName is
mycode.mywidget and bundleNames available include bundleone and
bundletwo:
Load translated resource bundles provided underneath the "nls"
mycode/
mywidget/
nls/
bundleone.js (the fallback translation, English in this example)
bundletwo.js (also a fallback translation)
de/
bundleone.js
bundletwo.js
de-at/
bundleone.js
en/
(empty; use the fallback translation)
en-us/
bundleone.js
en-gb/
bundleone.js
es/
bundleone.js
bundletwo.js
...etc
...
...
(
http://www.ietf.org/rfc/rfc3066.txt
), normalized in lowercase.
Note that the two bundles in the example do not define all the
same variants. For a given locale, bundles will be loaded for
that locale and all more general locales above it, including a
fallback at the root directory. For example, a declaration for
the "de-at" locale will first load nls/de-at/bundleone.js
,
then nls/de/bundleone.js
and finally nls/bundleone.js
. The
data will be flattened into a single Object so that lookups
will follow this cascading pattern. An optional build step can
preload the bundles to avoid data redundancy and the multiple
network hits normally required to load these resources.
Each directory is named for a locale as specified by RFC 3066,
Usage
parameter | type | description |
---|---|---|
moduleName | String | |
bundleName | String | |
locale | String | Optional. |
availableFlatLocales | String |