Issue #2224691 by Sweetchuck: JavaScript Drupal.t and Drupal.formatPlural only works for non-english languages.
parent
51d5481ddd
commit
bc11c5e5b2
|
@ -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'])) {
|
||||
|
|
Loading…
Reference in New Issue