--- includes/locale.inc	2010-01-04 13:40:18.000000000 -0600
+++ includes/locale.inc.modified2	2010-01-04 16:43:43.000000000 -0600
@@ -226,11 +226,11 @@ function locale_languages_custom_form($f
 /**
  * Editing screen for a particular language.
  *
- * @param $language
- *   A fully populated language object.
+ * @param $langcode
+ *   Language code of the language to edit.
  */
-function locale_languages_edit_form($form, &$form_state, $language) {
-  if ($language) {
+function locale_languages_edit_form($form, &$form_state, $langcode) {
+  if ($language = db_query("SELECT * FROM {languages} WHERE language = :language", array(':language' => $langcode))->fetchObject()) {
     _locale_languages_common_controls($form, $language);
     $form['submit'] = array(
       '#type' => 'submit',
@@ -426,19 +426,16 @@ function locale_languages_edit_form_subm
 
 /**
  * User interface for the language deletion confirmation screen.
- *
- * @param $language
- *   A fullly populated language object.
  */
-function locale_languages_delete_form($form, &$form_state, $language) {
+function locale_languages_delete_form($form, &$form_state, $langcode) {
 
   // Do not allow deletion of English locale.
-  if ($language->language == 'en') {
+  if ($langcode == 'en') {
     drupal_set_message(t('The English language cannot be deleted.'));
     drupal_goto('admin/config/regional/language');
   }
 
-  if (language_default('language') == $language->language) {
+  if (language_default('language') == $langcode) {
     drupal_set_message(t('The default language cannot be deleted.'));
     drupal_goto('admin/config/regional/language');
   }
@@ -446,13 +443,13 @@ function locale_languages_delete_form($f
   // For other languages, warn user that data loss is ahead.
   $languages = language_list();
 
-  if (!isset($languages[$language->language])) {
+  if (!isset($languages[$langcode])) {
     drupal_not_found();
     drupal_exit();
   }
   else {
-    $form['langcode'] = array('#type' => 'value', '#value' => $language->language);
-    return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$language->language]->name))), 'admin/config/regional/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel'));
+    $form['langcode'] = array('#type' => 'value', '#value' => $langcode);
+    return confirm_form($form, t('Are you sure you want to delete the language %name?', array('%name' => t($languages[$langcode]->name))), 'admin/config/regional/language', t('Deleting a language will remove all interface translations associated with it, and posts in this language will be set to be language neutral. This action cannot be undone.'), t('Delete'), t('Cancel'));
   }
 }
 
@@ -1379,11 +1376,14 @@ function locale_translate_export_po_form
 /**
  * User interface for string editing.
  */
-function locale_translate_edit_form($form, &$form_state, $source) {
+function locale_translate_edit_form($form, &$form_state, $lid) {
+  // Fetch source string, if possible.
+  $source = db_query('SELECT source, context, textgroup, location FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject();
   if (!$source) {
     drupal_set_message(t('String not found.'), 'error');
     drupal_goto('admin/config/regional/translate/translate');
   }
+
   // Add original text to the top and some values for form altering.
   $form['original'] = array(
     '#type'  => 'item',
@@ -1399,7 +1399,7 @@ function locale_translate_edit_form($for
   }
   $form['lid'] = array(
     '#type'  => 'value',
-    '#value' => $source->lid
+    '#value' => $lid
   );
   $form['textgroup'] = array(
     '#type'  => 'value',
@@ -1430,7 +1430,7 @@ function locale_translate_edit_form($for
   }
 
   // Fetch translations and fill in default values in the form.
-  $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = :lid AND language <> :omit", array(':lid' => $source->lid, ':omit' => $omit));
+  $result = db_query("SELECT DISTINCT translation, language FROM {locales_target} WHERE lid = :lid AND language <> :omit", array(':lid' => $lid, ':omit' => $omit));
   foreach ($result as $translation) {
     $form['translations'][$translation->language]['#default_value'] = $translation->translation;
   }
@@ -1532,22 +1532,26 @@ function locale_translate_edit_form_subm
  */
 
 /**
- * User interface for the string deletion confirmation screen.
- *
- * @param $source
- *  Afully populated translation source object.
+ * String deletion confirmation page.
  */
-function locale_translate_delete_form($form, &$form_state, $source) {
-  if ($source) {
-    $form['lid'] = array('#type' => 'value', '#value' => $source->lid);
-    return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel'));
+function locale_translate_delete_page($lid) {
+  if ($source = db_query('SELECT lid, source FROM {locales_source} WHERE lid = :lid', array(':lid' => $lid))->fetchObject()) {
+    return drupal_get_form('locale_translate_delete_form', $source);
   }
   else {
-    return druapl_not_found();
+    return drupal_not_found();
   }
 }
 
 /**
+ * User interface for the string deletion confirmation screen.
+ */
+function locale_translate_delete_form($form, &$form_state, $source) {
+  $form['lid'] = array('#type' => 'value', '#value' => $source->lid);
+  return confirm_form($form, t('Are you sure you want to delete the string "%source"?', array('%source' => $source->source)), 'admin/config/regional/translate/translate', t('Deleting the string will remove all translations of this string in all languages. This action cannot be undone.'), t('Delete'), t('Cancel'));
+}
+
+/**
  * Process string deletion submissions.
  */
 function locale_translate_delete_form_submit($form, &$form_state) {
@@ -2176,48 +2180,50 @@ function _locale_import_parse_plural_for
  */
 function _locale_import_parse_arithmetic($string) {
   // Operator precedence table
-  $prec = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
+  $precedence = array("(" => -1, ")" => -1, "?" => 1, ":" => 1, "||" => 3, "&&" => 4, "==" => 5, "!=" => 5, "<" => 6, ">" => 6, "<=" => 6, ">=" => 6, "+" => 7, "-" => 7, "*" => 8, "/" => 8, "%" => 8);
   // Right associativity
-  $rasc = array("?" => 1, ":" => 1);
+  $right_associativity = array("?" => 1, ":" => 1);
 
   $tokens = _locale_import_tokenize_formula($string);
 
   // Parse by converting into infix notation then back into postfix
-  $opstk = array();
-  $elstk = array();
+  // Operator stack - holds math operators and symbols
+  $operator_stack = array();
+  // Element Stack - holds data to be operated on
+  $element_stack = array();
 
   foreach ($tokens as $token) {
-    $ctok = $token;
+    $current_token = $token;
 
-    // Numbers and the $n variable are simply pushed into $elarr
+    // Numbers and the $n variable are simply pushed into $element_stack
     if (is_numeric($token)) {
-      $elstk[] = $ctok;
+      $element_stack[] = $current_token;
     }
-    elseif ($ctok == "n") {
-      $elstk[] = '$n';
+    elseif ($current_token == "n") {
+      $element_stack[] = '$n';
     }
-    elseif ($ctok == "(") {
-      $opstk[] = $ctok;
+    elseif ($current_token == "(") {
+      $operator_stack[] = $current_token;
     }
-    elseif ($ctok == ")") {
-      $topop = array_pop($opstk);
+    elseif ($current_token == ")") {
+      $topop = array_pop($operator_stack);
       while (isset($topop) && ($topop != "(")) {
-        $elstk[] = $topop;
-        $topop = array_pop($opstk);
+        $element_stack[] = $topop;
+        $topop = array_pop($operator_stack);
       }
     }
-    elseif (!empty($prec[$ctok])) {
-      // If it's an operator, then pop from $oparr into $elarr until the
-      // precedence in $oparr is less than current, then push into $oparr
-      $topop = array_pop($opstk);
-      while (isset($topop) && ($prec[$topop] >= $prec[$ctok]) && !(($prec[$topop] == $prec[$ctok]) && !empty($rasc[$topop]) && !empty($rasc[$ctok]))) {
-        $elstk[] = $topop;
-        $topop = array_pop($opstk);
+    elseif (!empty($precedence[$current_token])) {
+      // If it's an operator, then pop from $operator_stack into $element_stack until the
+      // precedence in $operator_stack is less than current, then push into $operator_stack
+      $topop = array_pop($operator_stack);
+      while (isset($topop) && ($precedence[$topop] >= $precedence[$current_token]) && !(($precedence[$topop] == $precedence[$current_token]) && !empty($right_associativity[$topop]) && !empty($right_associativity[$current_token]))) {
+        $element_stack[] = $topop;
+        $topop = array_pop($operator_stack);
       }
       if ($topop) {
-        $opstk[] = $topop;   // Return element to top
+        $operator_stack[] = $topop;   // Return element to top
       }
-      $opstk[] = $ctok;      // Parentheses are not needed
+      $operator_stack[] = $current_token;      // Parentheses are not needed
     }
     else {
       return FALSE;
@@ -2225,38 +2231,38 @@ function _locale_import_parse_arithmetic
   }
 
   // Flush operator stack
-  $topop = array_pop($opstk);
+  $topop = array_pop($operator_stack);
   while ($topop != NULL) {
-    $elstk[] = $topop;
-    $topop = array_pop($opstk);
+    $element_stack[] = $topop;
+    $topop = array_pop($operator_stack);
   }
 
   // Now extract formula from stack
-  $prevsize = count($elstk) + 1;
-  while (count($elstk) < $prevsize) {
-    $prevsize = count($elstk);
-    for ($i = 2; $i < count($elstk); $i++) {
-      $op = $elstk[$i];
-      if (!empty($prec[$op])) {
+  $previous_size = count($element_stack) + 1;
+  while (count($element_stack) < $previous_size) {
+    $previous_size = count($element_stack);
+    for ($i = 2; $i < count($element_stack); $i++) {
+      $op = $element_stack[$i];
+      if (!empty($precedence[$op])) {
         $f = "";
         if ($op == ":") {
-          $f = $elstk[$i - 2] . "):" . $elstk[$i - 1] . ")";
+          $f = $element_stack[$i - 2] . "):" . $element_stack[$i - 1] . ")";
         }
         elseif ($op == "?") {
-          $f = "(" . $elstk[$i - 2] . "?(" . $elstk[$i - 1];
+          $f = "(" . $element_stack[$i - 2] . "?(" . $element_stack[$i - 1];
         }
         else {
-          $f = "(" . $elstk[$i - 2] . $op . $elstk[$i - 1] . ")";
+          $f = "(" . $element_stack[$i - 2] . $op . $element_stack[$i - 1] . ")";
         }
-        array_splice($elstk, $i - 2, 3, $f);
+        array_splice($element_stack, $i - 2, 3, $f);
         break;
       }
     }
   }
 
   // If only one element is left, the number of operators is appropriate
-  if (count($elstk) == 1) {
-    return $elstk[0];
+  if (count($element_stack) == 1) {
+    return $element_stack[0];
   }
   else {
     return FALSE;
@@ -3293,3 +3299,4 @@ function locale_get_localized_date_forma
 
   return $formats;
 }
+
