summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-05-24 07:22:12 +0000
committerDries Buytaert <dries@buytaert.net>2010-05-24 07:22:12 +0000
commitfe0c128c71dc912250947bf90f6225357330c1c3 (patch)
tree3ccf0adb7158a945be73721773dbe9d515c83d7a
parent24b02d36b9812a536693fa126c3fa08a147440af (diff)
downloadbrdo-fe0c128c71dc912250947bf90f6225357330c1c3.tar.gz
brdo-fe0c128c71dc912250947bf90f6225357330c1c3.tar.bz2
- Patch #504506 by andypost: Drupal.formatPlural incorrectly handle complex plural rules.
-rw-r--r--includes/locale.inc31
-rw-r--r--misc/drupal.js2
2 files changed, 5 insertions, 28 deletions
diff --git a/includes/locale.inc b/includes/locale.inc
index 39908ce8a..9c383210f 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -1637,35 +1637,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 = :language WHERE s.location LIKE '%.js%' AND s.textgroup = :textgroup ORDER BY t.plural DESC", array(':language' => $language->language, ':textgroup' => 'default'));
+ // 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 = :language WHERE s.location LIKE '%.js%' AND s.textgroup = :textgroup AND t.translation IS NOT NULL", array(':language' => $language->language, ':textgroup' => 'default'));
- $translations = $plurals = array();
+ $translations = array();
foreach ($result as $data) {
- // 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 d6f7597c3..79f9f755c 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -216,7 +216,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);
}
};