summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGábor Hojtsy2012-01-23 13:03:11 (GMT)
committer Gábor Hojtsy2012-01-23 13:03:11 (GMT)
commitce003919b40308d9c743140e5b3ce6d898e5a072 (patch)
tree39180e214a7f009b4ad2ba9975cfce6b5a48383f
parentd9fb98f75d5557425ba1c18dfe068701425833d4 (diff)
Issue #504506 by andypost, pillarsdotnet, podarok: Drupal.formatPlural() did not pass on extra arguments for translations of some plural values
-rw-r--r--includes/locale.inc31
-rw-r--r--misc/drupal.js2
-rw-r--r--modules/locale/locale.install18
3 files changed, 23 insertions, 28 deletions
diff --git a/includes/locale.inc b/includes/locale.inc
index 8e03da4..e1692ca 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -2158,35 +2158,12 @@ function _locale_rebuild_js($langcode = NULL) {
}
// Construct the array for JavaScript translations.
- // We sort on plural so that we have all plural forms before singular forms.
- $result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.location LIKE '%%.js%%' AND s.textgroup = 'default' ORDER BY t.plural DESC", $language->language);
+ // Only add strings with a translation to the translations array.
+ $result = db_query("SELECT s.lid, s.source, t.translation FROM {locales_source} s INNER JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.location LIKE '%%.js%%' AND s.textgroup = 'default'", $language->language);
- $translations = $plurals = array();
+ $translations = array();
while ($data = db_fetch_object($result)) {
- // Only add this to the translations array when there is actually a translation.
- if (!empty($data->translation)) {
- if ($data->plural) {
- // When the translation is a plural form, first add it to another array and
- // wait for the singular (parent) translation.
- if (!isset($plurals[$data->plid])) {
- $plurals[$data->plid] = array($data->plural => $data->translation);
- }
- else {
- $plurals[$data->plid] += array($data->plural => $data->translation);
- }
- }
- elseif (isset($plurals[$data->lid])) {
- // There are plural translations for this translation, so get them from
- // the plurals array and add them to the final translations array.
- $translations[$data->source] = array($data->plural => $data->translation) + $plurals[$data->lid];
- unset($plurals[$data->lid]);
- }
- else {
- // There are no plural forms for this translation, so just add it to
- // the translations array.
- $translations[$data->source] = $data->translation;
- }
- }
+ $translations[$data->source] = $data->translation;
}
// Construct the JavaScript file, if there are translations.
diff --git a/misc/drupal.js b/misc/drupal.js
index c140c7c..f29e398 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -149,7 +149,7 @@ Drupal.formatPlural = function(count, singular, plural, args) {
else {
args['@count['+ index +']'] = args['@count'];
delete args['@count'];
- return Drupal.t(plural.replace('@count', '@count['+ index +']'));
+ return Drupal.t(plural.replace('@count', '@count['+ index +']'), args);
}
};
diff --git a/modules/locale/locale.install b/modules/locale/locale.install
index 9c54105..e29b6e5 100644
--- a/modules/locale/locale.install
+++ b/modules/locale/locale.install
@@ -225,6 +225,24 @@ function locale_update_6006() {
*/
/**
+ * @defgroup updates-6.x-extra Locale updates for 6.x
+ * @{
+ */
+
+/**
+ * Fix Drupal.formatPlural().
+ */
+function locale_update_6007() {
+ locale_inc_callback('_locale_invalidate_js');
+ return array();
+}
+
+/**
+ * @} End of "defgroup updates-6.x-extra"
+ * The next series of updates should start at 7000.
+ */
+
+/**
* Implementation of hook_uninstall().
*/
function locale_uninstall() {