Skip to content
Snippets Groups Projects
Commit bc11c5e5 authored by Angie Byron's avatar Angie Byron
Browse files

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
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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.
......
......@@ -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);
......
......@@ -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'])) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment