Index: includes/locale.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/locale.inc,v
retrieving revision 1.130
diff -u -r1.130 locale.inc
--- includes/locale.inc	28 May 2007 06:08:38 -0000	1.130
+++ includes/locale.inc	29 May 2007 12:12:48 -0000
@@ -37,10 +37,9 @@
     '#options' => $options,
     '#default_value' => $enabled,
   );
-  $default = language_default();
   $form['site_default'] = array('#type' => 'radios',
     '#options' => $options,
-    '#default_value' => $default->language,
+    '#default_value' => language_default('language'),
   );
   $form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
   $form['#theme'] = 'locale_languages_overview_form';
@@ -323,8 +322,7 @@
   if (!empty($form_values['domain']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE domain = '%s' AND language != '%s'", $form_values['domain'], $form_values['langcode']))) {
     form_set_error('domain', t('The domain (%domain) is already tied to a language (%language).', array('%domain' => $form_values['domain'], '%language' => $duplicate->language)));
   }
-  $default = language_default();
-  if (empty($form_values['prefix']) && $default->language != $form_values['langcode'] && empty($form_values['domain'])) {
+  if (empty($form_values['prefix']) && language_default('language') != $form_values['langcode'] && empty($form_values['domain'])) {
     form_set_error('prefix', t('Only the default language can have both the domain and prefix empty.'));
   }
   if (!empty($form_values['prefix']) && $duplicate = db_fetch_object(db_query("SELECT language FROM {languages} WHERE prefix = '%s' AND language != '%s'", $form_values['prefix'], $form_values['langcode']))) {
@@ -368,8 +366,7 @@
     drupal_goto('admin/settings/language');
   }
 
-  $default = language_default();
-  if ($default->language == $langcode) {
+  if (language_default('language') == $langcode) {
     drupal_set_message(t('The default language cannot be deleted.'));
     drupal_goto('admin/settings/language');
   }
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.167
diff -u -r1.167 bootstrap.inc
--- includes/bootstrap.inc	25 May 2007 21:01:29 -0000	1.167
+++ includes/bootstrap.inc	29 May 2007 12:12:42 -0000
@@ -1053,9 +1053,13 @@
 
 /**
  * Default language used on the site
+ * 
+ * @param $property
+ *   Optional property of the language object to return
  */
-function language_default() {
-  return variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0));
+function language_default($property = NULL) {
+  $language = variable_get('language_default', (object) array('language' => 'en', 'name' => 'English', 'native' => 'English', 'direction' => 0, 'enabled' => 1, 'plurals' => 0, 'formula' => '', 'domain' => '', 'prefix' => '', 'weight' => 0));
+  return $property ? $language->$property : $language;
 }
 
 
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.646
diff -u -r1.646 common.inc
--- includes/common.inc	27 May 2007 20:31:13 -0000	1.646
+++ includes/common.inc	29 May 2007 12:12:45 -0000
@@ -835,9 +835,12 @@
  *
  * Arbitrary elements may be added using the $args associative array.
  */
-function format_rss_channel($title, $link, $description, $items, $language = 'en', $args = array()) {
+function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) {
+  global $language;
+  $langcode = $langcode ? $langcode : $language->language;
+  
   // arbitrary elements may be added using the $args associative array
-
+  
   $output = "<channel>\n";
   $output .= ' <title>'. check_plain($title) ."</title>\n";
   $output .= ' <link>'. check_url($link) ."</link>\n";
@@ -846,7 +849,7 @@
   // We strip all HTML tags, but need to prevent double encoding from properly
   // escaped source data (such as &amp becoming &amp;amp;).
   $output .= ' <description>'. check_plain(decode_entities(strip_tags($description))) ."</description>\n";
-  $output .= ' <language>'. check_plain($language) ."</language>\n";
+  $output .= ' <language>'. check_plain($langcode) ."</language>\n";
   $output .= format_xml_elements($args);
   $output .= $items;
   $output .= "</channel>\n";
@@ -948,30 +951,33 @@
  *      content (check_plain + theme_placeholder)
  *   Note that you do not need to include @count in this array.
  *   This replacement is done automatically for the plural case.
+ * @param $langcode
+ *   Optional language code to translate to a language other than
+ *   what is used to display the page.
  * @return
  *   A translated string.
  */
-function format_plural($count, $singular, $plural, $args = array()) {
+function format_plural($count, $singular, $plural, $args = array(), $langcode = NULL) {
   if ($count == 1) {
     return t($singular, $args);
   }
   $args['@count'] = $count;
 
   // get the plural index through the gettext formula
-  $index = (function_exists('locale_get_plural')) ? locale_get_plural($count) : -1;
+  $index = (function_exists('locale_get_plural')) ? locale_get_plural($count, $langcode) : -1;
   if ($index < 0) { // backward compatibility
-    return t($plural, $args);
+    return t($plural, $args, $langcode);
   }
   else {
     switch ($index) {
       case "0":
-        return t($singular, $args);
+        return t($singular, $args, $langcode);
       case "1":
-        return t($plural, $args);
+        return t($plural, $args, $langcode);
       default:
         unset($args['@count']);
         $args['@count['. $index .']'] = $count;
-        return t(strtr($plural, array('@count' => '@count['. $index .']')), $args);
+        return t(strtr($plural, array('@count' => '@count['. $index .']')), $args, $langcode);
     }
   }
 }
@@ -1002,21 +1008,24 @@
  *
  * @param $size
  *   The size in bytes.
+ * @param $langcode
+ *   Optional language code to translate to a language other than
+ *   what is used to display the page.
  * @return
  *   A translated string representation of the size.
  */
-function format_size($size) {
+function format_size($size, $langcode = NULL) {
   if ($size < 1024) {
-    return format_plural($size, '1 byte', '@count bytes');
+    return format_plural($size, '1 byte', '@count bytes', array(), $langcode);
   }
   else {
     $size = round($size / 1024, 2);
-    $suffix = t('KB');
+    $suffix = t('KB', 0, $langcode);
     if ($size >= 1024) {
       $size = round($size / 1024, 2);
-      $suffix = t('MB');
+      $suffix = t('MB', 0, $langcode);
     }
-    return t('@size @suffix', array('@size' => $size, '@suffix' => $suffix));
+    return t('@size @suffix', array('@size' => $size, '@suffix' => $suffix), $langcode);
   }
 }
 
@@ -1027,16 +1036,19 @@
  *   The length of the interval in seconds.
  * @param $granularity
  *   How many different units to display in the string.
+ * @param $langcode
+ *   Optional language code to translate to a language other than
+ *   what is used to display the page.
  * @return
  *   A translated string representation of the interval.
  */
-function format_interval($timestamp, $granularity = 2) {
+function format_interval($timestamp, $granularity = 2, $langcode = NULL) {
   $units = array('1 year|@count years' => 31536000, '1 week|@count weeks' => 604800, '1 day|@count days' => 86400, '1 hour|@count hours' => 3600, '1 min|@count min' => 60, '1 sec|@count sec' => 1);
   $output = '';
   foreach ($units as $key => $value) {
     $key = explode('|', $key);
     if ($timestamp >= $value) {
-      $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1]);
+      $output .= ($output ? ' ' : '') . format_plural(floor($timestamp / $value), $key[0], $key[1], array(), $langcode);
       $timestamp %= $value;
       $granularity--;
     }
@@ -1045,7 +1057,7 @@
       break;
     }
   }
-  return $output ? $output : t('0 sec');
+  return $output ? $output : t('0 sec', 0, $langcode);
 }
 
 /**
@@ -1066,10 +1078,13 @@
  *   format.
  * @param $timezone
  *   Time zone offset in seconds; if omitted, the user's time zone is used.
+ * @param $langcode
+ *   Optional language code to translate to a language other than
+ *   what is used to display the page.
  * @return
  *   A translated date string in the requested format.
  */
-function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL) {
+function format_date($timestamp, $type = 'medium', $format = '', $timezone = NULL, $langcode = NULL) {
   if (!isset($timezone)) {
     global $user;
     if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
@@ -1102,7 +1117,7 @@
   for ($i = 0; $i < $max; $i++) {
     $c = $format[$i];
     if (strpos('AaDFlM', $c) !== FALSE) {
-      $date .= t(gmdate($c, $timestamp));
+      $date .= t(gmdate($c, $timestamp), 0, $langcode);
     }
     else if (strpos('BdgGhHiIjLmnsStTUwWYyz', $c) !== FALSE) {
       $date .= gmdate($c, $timestamp);
Index: modules/aggregator/aggregator.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.module,v
retrieving revision 1.340
diff -u -r1.340 aggregator.module
--- modules/aggregator/aggregator.module	28 May 2007 06:08:38 -0000	1.340
+++ modules/aggregator/aggregator.module	29 May 2007 12:12:49 -0000
@@ -1250,7 +1250,7 @@
 
   $output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
   $output .= "<rss version=\"2.0\">\n";
-  $output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, array('absolute' => TRUE)), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items, 'en');
+  $output .= format_rss_channel(variable_get('site_name', 'Drupal') . ' ' . t('aggregator'), url('aggregator' . $url, array('absolute' => TRUE)), variable_get('site_name', 'Drupal') . ' - ' . t('aggregated feeds') . $title, $items);
   $output .= "</rss>\n";
 
   drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
Index: modules/locale/locale.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v
retrieving revision 1.175
diff -u -r1.175 locale.module
--- modules/locale/locale.module	28 May 2007 06:08:42 -0000	1.175
+++ modules/locale/locale.module	29 May 2007 12:12:50 -0000
@@ -190,8 +190,7 @@
     $languages = language_list('enabled');
     $languages = $languages['1'];
     if ($user->language == '') {
-      $default = language_default();
-      $user->language = $default->language;
+      $user->language = language_default('language');
     }
     $names = array();
     foreach ($languages as $langcode => $language) {
@@ -367,26 +366,35 @@
  * Returns plural form index for a specific number.
  *
  * The index is computed from the formula of this language.
+ * 
+ * @param $count
+ *   Number to return plural for
+ * @param $langcode
+ *   Optional language code to translate to a language other than
+ *   what is used to display the page.
  */
-function locale_get_plural($count) {
+function locale_get_plural($count, $langcode = NULL) {
   global $language;
   static $locale_formula, $plurals = array();
 
-  if (!isset($plurals[$count])) {
+  $langcode = $langcode ? $langcode : $language->language;
+  
+  if (!isset($plurals[$langcode][$count])) {
     if (!isset($locale_formula)) {
-      $locale_formula = $language->formula;
+      $language_list = language_list();
+      $locale_formula[$langcode] = $language_list[$langcode]->formula;
     }
-    if ($locale_formula) {
+    if ($locale_formula[$langcode]) {
       $n = $count;
-      $plurals[$count] = @eval("return intval($locale_formula);");
-      return $plurals[$count];
+      $plurals[$langcode][$count] = @eval("return intval($locale_formula);");
+      return $plurals[$langcode][$count];
     }
     else {
-      $plurals[$count] = -1;
+      $plurals[$langcode][$count] = -1;
       return -1;
     }
   }
-  return $plurals[$count];
+  return $plurals[$langcode][$count];
 }
 
 
