How to get Dutch at Dojo for work?

I need to format the date in Dutch (Dutch, Dutch). I found that dojo supports this, but I cannot get it to work. I am new to Javascript. Do not underestimate my blissful ignorance.

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 spanks me:

Package not found: gregorian in dojo.cldr, locale = nl-nl

(function () {var _1 = null; if ((_ 1 || (typeof .... setTimeout (dojo._ loadInit, 1000);}}) (); \ n

+4
source share
4 answers

Felix, try again. You should simply specify the language (s) that you want to use on the page at load time, in a tag that includes dojo.js. Then there is no need to mention this elsewhere if you do not want to support multiple locales on the page using 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 do not specify this, the default locale will use navigator.language, which is the installed language of your browser. Leaving the "locale" argument outside the format call, you usually want to do this. Then it will simply raise the default value for this page.

+4
source

Dojo standard packages come with a set of locales. You need to run the script to create the missing ones. See My instructions on the Dojo website: Built-in locales, adding locales with a custom assembly :

  • Run ANT build dojo-src/util/buildscripts/cldr
  • Run Dojo build with the localeList parameter
  • Specify djConfig.locale or add djConfig.extraLocale

Alternatively, you can use the Google CDN version in which all locales have already been created and define djConfig.extraLocale .

+4
source

Your code will work if you included dojo from the local URI. Cross-domain requires forced asynchrony. See this dojo forum post on this issue.

You can use dojo.addOnLoad to get around this problem:

 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); }); 

However, then he complains about your language pack. But this is a completely different story.

+1
source

I'm tired of it. This is encoded in a DIY way. Tough luck for dojo.

  function formatDutchDate(date) { monthnames = ['januari','februari','maart','april','mei','juni','juli','augustus','september','oktober','november','december']; monthname = monthnames[date.getMonth()]; return date.getDate()+' '+monthname+' '+date.getFullYear(); } 
0
source

All Articles