diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 0a2e70e..144898e 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -935,11 +935,11 @@ function locale_css_alter(&$css) {
  * Provides the language support for the jQuery UI Date Picker.
  */
 function locale_library_info_alter(&$libraries, $module) {
-  global $language;
-  if ($module == 'system' && isset($libraries['system']['ui.datepicker'])) {
+  if ($module == 'system' && isset($libraries['ui.datepicker'])) {
+    global $language;
     $datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
-    $libraries['system']['ui.datepicker']['js'][$datepicker] = array('group' => JS_THEME);
-    $libraries['system']['ui.datepicker']['js'][] = array(
+    $libraries['ui.datepicker']['js'][$datepicker] = array('scope' => 'footer', 'group' => JS_THEME);
+    $libraries['ui.datepicker']['js'][] = array(
       'data' => array(
         'jqueryuidatepicker' => array(
           'rtl' => $language->direction == LANGUAGE_RTL,
diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test
index 842b8f5..1687d49 100644
--- a/core/modules/locale/locale.test
+++ b/core/modules/locale/locale.test
@@ -2742,3 +2742,33 @@ class LocaleLanguageNegotiationInfoFunctionalTest extends DrupalWebTestCase {
     }
   }
 }
+
+/**
+ * Functional test for localization of the javascript libraries.
+ *
+ * Currently only the jQuery datepicker is localized, using Drupal translations.
+ */
+class LocaleLibraryInfoAlterTest extends DrupalWebTestCase {
+  public static function getInfo() {
+    return array(
+      'name' => 'Javascript library localisation',
+      'description' => 'Tests the localisation of javascript libraries.',
+      'group' => 'Locale',
+    );
+  }
+
+  function setUp() {
+    parent::setUp('locale', 'locale_test');
+  }
+
+  /**
+  * Verify that locale_library_info_alter adds localisation to the datepicker.
+  *
+  * @see locale_library_info_alter()
+  */
+  public function testLibraryInfoAlter() {
+    drupal_add_library('system', 'ui.datepicker');
+    $scripts = drupal_get_js('footer');
+    $this->assertTrue(strpos($scripts, 'locale.datepicker.js'), t('locale.datepicker.js added to scripts in footer.'));
+  }
+}
