Commit bc11c5e5 authored by webchick's avatar webchick

Issue #2224691 by Sweetchuck: JavaScript Drupal.t and Drupal.formatPlural only...

Issue #2224691 by Sweetchuck: JavaScript Drupal.t and Drupal.formatPlural only works for non-english languages.
parent 51d5481d
...@@ -2073,7 +2073,12 @@ function _drupal_add_js($data = NULL, $options = NULL) { ...@@ -2073,7 +2073,12 @@ function _drupal_add_js($data = NULL, $options = NULL) {
ksort($current_query); ksort($current_query);
$path['currentQuery'] = (object) $current_query; $path['currentQuery'] = (object) $current_query;
} }
$javascript['settings']['data'][] = array('path' => $path); $javascript['settings']['data'][] = array(
'path' => $path,
'locale' => array(
'pluralDelimiter' => LOCALE_PLURAL_DELIMITER,
),
);
} }
// All JavaScript settings are placed in the header of the page with // All JavaScript settings are placed in the header of the page with
// the library weight so that inline scripts appear afterwards. // the library weight so that inline scripts appear afterwards.
......
...@@ -364,7 +364,7 @@ if (window.jQuery) { ...@@ -364,7 +364,7 @@ if (window.jQuery) {
args = args || {}; args = args || {};
args['@count'] = count; args['@count'] = count;
var pluralDelimiter = Drupal.locale.pluralDelimiter; var pluralDelimiter = drupalSettings.locale.pluralDelimiter;
// Determine the index of the plural form. // Determine the index of the plural form.
var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] === 1) ? 0 : 1); var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] === 1) ? 0 : 1);
......
...@@ -1296,9 +1296,7 @@ function _locale_rebuild_js($langcode = NULL) { ...@@ -1296,9 +1296,7 @@ function _locale_rebuild_js($langcode = NULL) {
$data_hash = NULL; $data_hash = NULL;
$data = $status = ''; $data = $status = '';
if (!empty($translations)) { if (!empty($translations)) {
$data = array( $data = array();
'pluralDelimiter: ' . Json::encode(LOCALE_PLURAL_DELIMITER),
);
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
if (!empty($locale_plurals[$language->id]['formula'])) { if (!empty($locale_plurals[$language->id]['formula'])) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment