title: Setting date format on datepicker.js from datepicker localization file
body: <p>Localizing jquery ui datepicker with an i18n localization file is pretty straightforward but setting the datepicker's <code>dateFormat</code> property to the default property found in hte i18n file is proving challenging. In the following file for France you can see the default date format specifying day,month,year  </p>
  
  <pre><code>(function( factory ) {
  if ( typeof define === "function" &amp;&amp; define.amd ) {
  
      // AMD. Register as an anonymous module.
      define([ "../datepicker" ], factory );
  } else {
  
      // Browser globals
      factory( jQuery.datepicker );
  }
  }(function( datepicker ) {
  
  datepicker.regional['fr'] = {
  closeText: 'Fermer',
  prevText: 'Précédent',
  nextText: 'Suivant',
  currentText: 'Aujourd\'hui',
  monthNames: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
      'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
  monthNamesShort: ['janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin',
      'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.'],
  dayNames: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
  dayNamesShort: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
  dayNamesMin: ['D','L','M','M','J','V','S'],
  weekHeader: 'Sem.',
  dateFormat: 'dd/mm/yy',
  firstDay: 1,
  isRTL: false,
  showMonthAfterYear: false,
  yearSuffix: ''};
  datepicker.setDefaults(datepicker.regional['fr']);
  
  return datepicker.regional['fr'];
  
  }));
  </code></pre>
  
  <p>This is how I am setting the localization file dynamically at runtime.  </p>
  
  <pre><code> if (General.CountryCode != "US") {
              var scriptUrl = "/Scripts/datepicker-glob/datepicker-" + General.CountryCode.toLowerCase() + ".js";
  
              console.log("fetching script: ", scriptUrl);
              //now get datepicker local file and load it into the dom
              $.getScript(scriptUrl).fail(function() {
                  console.log("script fetch failed");
              });
              console.log("loaded script. Setting defaults for datepicker");
              //console.log("dateformat: ", $.datepicker.regional[General.CountryCode.toLowerCase()].dateFormat);
              //now set the default on all datepickers
              console.log($.datepicker);
              //console.log($.datepicker);
              $.datepicker.setDefaults(
                 $.extend(
                    {
                        'dateFormat': $.datepicker.regional[0].dateFormat
                    },
                   $.datepicker.regional[General.CountryCode.toLowerCase()]
                  )
                );
              console.log("defaults set.");
          }  
  </code></pre>
  
  <p>The following line <code>'dateFormat': $.datepicker.regional[0].dateFormat</code> in the <code>$.extend</code> fails because <code>$.datepicker.regional[0]</code> seems to be undefined; however, the following line <code>console.log($.datepicker);</code> returns the following:  </p>
  
  <p><img src="https://i.stack.imgur.com/YWs2z.png" alt="enter image description here">  </p>
  
  <p>According to that shot it looks as if my code should be working. </p>
  
  <p><strong>How can I correctly retrieve the regional dateFormat value from a dynamically loaded i18n file?</strong></p>