Issue #2224691 by Sweetchuck: JavaScript Drupal.t and Drupal.formatPlural only works for non-english languages.

8.0.x
webchick 2014-03-26 22:03:11 -07:00
parent 51d5481ddd
commit bc11c5e5b2
3 changed files with 8 additions and 5 deletions

View File

@ -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.

View File

@ -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);

View File

@ -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'])) {