function locale_library_info_alter

Implement hook_library_info_alter().

Provides the language support for the jQuery UI Date Picker.

File

drupal/core/modules/locale/locale.module, line 615
Enables the translation of the user interface to languages other than English.

Code

function locale_library_info_alter(&$libraries, $module) {
  if ($module == 'system' && isset($libraries['jquery.ui.datepicker'])) {
    $language_interface = language(Language::TYPE_INTERFACE);

    // locale.datepicker.js should be added in the JS_LIBRARY group, so that
    // this attach behavior will execute early. JS_LIBRARY is the default for
    // hook_library_info_alter(), thus does not have to be specified explicitly.
    $libraries['jquery.ui.datepicker']['dependencies'][] = array(
      'locale',
      'drupal.locale.datepicker',
    );
    $libraries['jquery.ui.datepicker']['js'][] = array(
      'data' => array(
        'jquery' => array(
          'ui' => array(
            'datepicker' => array(
              'isRTL' => $language_interface->direction == Language::DIRECTION_RTL,
              'firstDay' => config('system.date')
                ->get('first_day'),
            ),
          ),
        ),
      ),
      'type' => 'setting',
    );
  }
}