summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-03-27 05:03:11 (GMT)
committerwebchick2014-03-27 05:03:11 (GMT)
commitbc11c5e5b29634ece3164fc8b91babc69739f825 (patch)
tree5fa147d0b8ff84f1b2360740040968da34cc90b5
parent51d5481ddd8ab65765c18812a9af829f0d04bdd0 (diff)
Issue #2224691 by Sweetchuck: JavaScript Drupal.t and Drupal.formatPlural only works for non-english languages.
-rw-r--r--core/includes/common.inc7
-rw-r--r--core/misc/drupal.js2
-rw-r--r--core/modules/locale/locale.module4
3 files changed, 8 insertions, 5 deletions
diff --git a/core/includes/common.inc b/core/includes/common.inc
index 9489e03..9ec0e86 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -2073,7 +2073,12 @@ function _drupal_add_js($data = NULL, $options = NULL) {
ksort($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
// the library weight so that inline scripts appear afterwards.
diff --git a/core/misc/drupal.js b/core/misc/drupal.js
index b8c0077..afac700 100644
--- a/core/misc/drupal.js
+++ b/core/misc/drupal.js
@@ -364,7 +364,7 @@ if (window.jQuery) {
args = args || {};
args['@count'] = count;
- var pluralDelimiter = Drupal.locale.pluralDelimiter;
+ var pluralDelimiter = drupalSettings.locale.pluralDelimiter;
// Determine the index of the plural form.
var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] === 1) ? 0 : 1);
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index 72ff183..8d1e09d 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -1296,9 +1296,7 @@ function _locale_rebuild_js($langcode = NULL) {
$data_hash = NULL;
$data = $status = '';
if (!empty($translations)) {
- $data = array(
- 'pluralDelimiter: ' . Json::encode(LOCALE_PLURAL_DELIMITER),
- );
+ $data = array();
$locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array();
if (!empty($locale_plurals[$language->id]['formula'])) {