Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Dutch locale in Dojo to work?

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

like image 965
Felix Ogg Avatar asked Jan 23 '23 20:01

Felix Ogg


2 Answers

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.

like image 108
peller Avatar answered Feb 02 '23 15:02

peller


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:

  1. Run ANT build in dojo-src/util/buildscripts/cldr
  2. Run Dojo build with localeList parameter
  3. Specify djConfig.locale or add djConfig.extraLocale

Alternatively you can use Google CDN version where all the locals have been created already AND define djConfig.extraLocale.

like image 36
Maine Avatar answered Feb 02 '23 16:02

Maine