Skip to content

Commit

Permalink
allow access to locales other than dojo.locale when using requirejs. …
Browse files Browse the repository at this point in the history
…refs #12200 !strict.

git-svn-id: http://svn.dojotoolkit.org/src/dojo/trunk@23742 560b804f-0ae3-0310-86f3-f6aa0a117693
  • Loading branch information
neonstalwart committed Feb 7, 2011
1 parent c68a730 commit 580c26e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
11 changes: 3 additions & 8 deletions lib/backCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,10 @@ define(["require", "dojo/_base/_loader/bootstrap"], function(require, dojo){
};

dojo.requireLocalization = function(moduleName, bundleName, locale){
// requirejs (as of 0.22.0) is not able to handle synchronous require requests for plugin modules.
// Consequently, although the dojo/dijit v1.6 code stack automatically preloads all i18n bundles
// for the default locale, requirejs is unable to return these bundles synchronously. Therefore,
// if requirejs is detected, always request the default locale. Note: if you want to gain access to
// a bundle from another locale, you must change the requirejs locale, make an asynchronous request
// for the bundle, and only after that async request returns can you get access to the bundle
// through this backcompat routine.
// NOTE: locales other than the locale specified in dojo.locale need to be specifically
// declared as a module dependency when using AMD.
if(require.vendor!="altoviso.com"){
locale= "root";
locale = !locale || locale.toLowerCase() === dojo.locale ? "root" : locale;
}
return require(dojo.getL10nName(moduleName, bundleName, locale));
};
Expand Down
5 changes: 4 additions & 1 deletion tests/amd/smoke-requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
"require/i18n":"../../../../requirejs/require/i18n",
"require/text":"../../../../requirejs/require/text"
},
deps:["dojo", "dojo/date/locale", "text!smoke.txt"],
deps:["dojo", "dojo/date/locale", "text!smoke.txt", "i18n!dojo/cldr/nls/fr-ch/gregorian"],
callback:function(dojo, locale, text){
dojo.byId("status").innerHTML= "The dojo package has been loaded.";
dojo.byId("time").innerHTML= (((new Date()).getTime() - start) / 1000) + "s";
dojo.byId("i18n").innerHTML= locale.getNames('months', 'wide', 'standAlone');
// test specifying a different locale that depends on "parent" bundles (ie depends on 'fr' bundle)
dojo.byId("frch").innerHTML= locale.getNames('months', 'wide', 'standAlone', 'fr-ch');
dojo.byId("text").innerHTML= text;
}
});
Expand All @@ -37,6 +39,7 @@ <h1>Load Time</h1>
<p id="time"></p>
<h1>Plugin Smoke Test</h1>
<p id="i18n"></p>
<p id="frch"></p>
<p id="text"></p>
</body>
</html>
Expand Down

0 comments on commit 580c26e

Please sign in to comment.