I need to format a date into a Dutch locale (Netherlands, Dutch language) string. I found that dojo supports this, but I can't get it to work. I am a Javascript newbie. Don't underestimate my blissful ignorence.
EDITED
<html>
<title>title</title>
<body>
<SCRIPT TYPE="text/javascript" SRC="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js">
</SCRIPT>
<script type="text/javascript">
dojo.require("dojo.date");
dojo.require("dojo.date.locale");
dojo.addOnLoad(function() {
var d = new Date('2009/12/23');
console.log(d, dojo, dojo.date);
var dstr = dojo.date.locale.format(d, {locale:'nl-nl'});
document.write(dstr);
});
</script>
</body>
Firebug slaps me with:
Bundle not found: gregorian in dojo.cldr , locale=nl-nl
(function(){var _1=null;if((_1||(typeof ....setTimeout(dojo._loadInit,1000);}})();\n
Felix, please give it another try. You must simply specify the locale(s) you wish to use on the page at bootstrap time, in the tag that includes dojo.js. Then, there's no need to mention it anywhere else, unless you wish to support multiple locales on a page with djConfig.extraLocale
<SCRIPT TYPE="text/javascript" SRC="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js" djConfig="locale: 'nl'">
If you don't specify this, the locale defaults to navigator.language, which is the installed language of your browser. Leaving the "locale" argument off the format call is what you typically would want to do. Then it will just pick up the default for that page.
Standard Dojo packages come with a selection of locales. You need to run a script to create the missing ones. See my instructions at the Dojo website: Built-in locales, adding locales with custom build:
dojo-src/util/buildscripts/cldr
localeList
parameterdjConfig.locale
or add djConfig.extraLocale
Alternatively you can use Google CDN version where all the locals have been created already AND define djConfig.extraLocale.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With