Index: install.php
===================================================================
RCS file: /cvs/drupal/drupal/install.php,v
retrieving revision 1.217
diff -u -p -r1.217 install.php
--- install.php	13 Oct 2009 14:15:08 -0000	1.217
+++ install.php	15 Oct 2009 04:53:52 -0000
@@ -242,12 +242,13 @@ function install_begin_request(&$install
   require_once DRUPAL_ROOT . '/includes/file.inc';
   require_once DRUPAL_ROOT . '/includes/path.inc';
 
-  // Set up $language, so t() caller functions will still work.
-  drupal_language_initialize();
-
   // Load module basics (needed for hook invokes).
   include_once DRUPAL_ROOT . '/includes/module.inc';
   include_once DRUPAL_ROOT . '/includes/session.inc';
+
+  // Set up $language, so t() caller functions will still work.
+  drupal_language_initialize();
+
   include_once DRUPAL_ROOT . '/includes/entity.inc';
   $module_list['system']['filename'] = 'modules/system/system.module';
   $module_list['filter']['filename'] = 'modules/filter/filter.module';
Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.309
diff -u -p -r1.309 bootstrap.inc
--- includes/bootstrap.inc	9 Oct 2009 16:33:13 -0000	1.309
+++ includes/bootstrap.inc	15 Oct 2009 04:53:52 -0000
@@ -1638,6 +1638,9 @@ function drupal_language_initialize() {
     foreach ($types as $type) {
       $GLOBALS[$type] = language_initialize($type);
     }
+    // Allow modules to react on language system initialization in multilingual
+    // environments.
+    module_invoke_all('language_init', $types);
   }
 }
 
Index: includes/menu.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/menu.inc,v
retrieving revision 1.352
diff -u -p -r1.352 menu.inc
--- includes/menu.inc	11 Oct 2009 19:39:30 -0000	1.352
+++ includes/menu.inc	15 Oct 2009 04:53:53 -0000
@@ -907,8 +907,8 @@ function menu_tree_all_data($menu_name, 
 
   // Use $mlid as a flag for whether the data being loaded is for the whole tree.
   $mlid = isset($link['mlid']) ? $link['mlid'] : 0;
-  // Generate a cache ID (cid) specific for this $menu_name, $item, and depth.
-  $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . (int)$max_depth;
+  // Generate a cache ID (cid) specific for this $menu_name, $link, $language, and depth.
+  $cid = 'links:' . $menu_name . ':all-cid:' . $mlid . ':' . $GLOBALS['language_interface']->language . ':' . (int)$max_depth;
 
   if (!isset($tree[$cid])) {
     // If the static variable doesn't have the data, check {cache_menu}.
@@ -926,6 +926,7 @@ function menu_tree_all_data($menu_name, 
       // Build the query using a LEFT JOIN since there is no match in
       // {menu_router} for an external link.
       $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
+      $query->addTag('translatable');
       $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
       $query->fields('ml');
       $query->fields('m', array(
@@ -1018,7 +1019,7 @@ function menu_tree_page_data($menu_name,
       $max_depth = min($max_depth, MENU_MAX_DEPTH);
     }
     // Generate a cache ID (cid) specific for this page.
-    $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . (int)$item['access'] . ':' . (int)$max_depth;
+    $cid = 'links:' . $menu_name . ':page-cid:' . $item['href'] . ':' . $GLOBALS['language_interface']->language . ':' . (int)$item['access'] . ':' . (int)$max_depth;
 
     if (!isset($tree[$cid])) {
       // If the static variable doesn't have the data, check {cache_menu}.
@@ -1109,6 +1110,7 @@ function menu_tree_page_data($menu_name,
         // LEFT JOIN since there is no match in {menu_router} for an external
         // link.
         $query = db_select('menu_links', 'ml', array('fetch' => PDO::FETCH_ASSOC));
+        $query->addTag('translatable');
         $query->leftJoin('menu_router', 'm', 'm.path = ml.router_path');
         $query->fields('ml');
         $query->fields('m', array(
@@ -1164,7 +1166,7 @@ function menu_tree_page_data($menu_name,
  * Helper function - compute the real cache ID for menu tree data.
  */
 function _menu_tree_cid($menu_name, $data) {
-  return 'links:' . $menu_name . ':tree-data:' . md5(serialize($data));
+  return 'links:' . $menu_name . ':tree-data:' . $GLOBALS['language_interface']->language . ':' . md5(serialize($data));
 }
 
 /**
Index: includes/database/select.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database/select.inc,v
retrieving revision 1.24
diff -u -p -r1.24 select.inc
--- includes/database/select.inc	18 Sep 2009 00:04:21 -0000	1.24
+++ includes/database/select.inc	15 Oct 2009 04:53:53 -0000
@@ -1285,6 +1285,11 @@ class SelectQuery extends Query implemen
 
     // FIELDS and EXPRESSIONS
     $fields = array();
+    foreach ($this->tables as $alias => $table) {
+      if (!empty($table['all_fields'])) {
+        $fields[] = $alias . '.*';
+      }
+    }
     foreach ($this->fields as $alias => $field) {
       // Always use the AS keyword for field aliases, as some
       // databases require it (e.g., PostgreSQL).
@@ -1293,11 +1298,6 @@ class SelectQuery extends Query implemen
     foreach ($this->expressions as $alias => $expression) {
       $fields[] = $expression['expression'] . ' AS ' . $expression['alias'];
     }
-    foreach ($this->tables as $alias => $table) {
-      if (!empty($table['all_fields'])) {
-        $fields[] = $alias . '.*';
-      }
-    }
     $query .= implode(', ', $fields);
 
 
Index: modules/contact/contact.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.install,v
retrieving revision 1.20
diff -u -p -r1.20 contact.install
--- modules/contact/contact.install	12 Oct 2009 15:17:51 -0000	1.20
+++ modules/contact/contact.install	15 Oct 2009 04:53:53 -0000
@@ -25,6 +25,7 @@ function contact_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'Category name.',
+        'translatable' => TRUE,
       ),
       'recipients' => array(
         'type' => 'text',
Index: modules/contact/contact.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/contact/contact.pages.inc,v
retrieving revision 1.32
diff -u -p -r1.32 contact.pages.inc
--- modules/contact/contact.pages.inc	11 Oct 2009 18:34:10 -0000	1.32
+++ modules/contact/contact.pages.inc	15 Oct 2009 04:53:53 -0000
@@ -24,7 +24,13 @@ function contact_site_form($form, &$form
   }
 
   // Get an array of the categories and the current default category.
-  $categories = db_query("SELECT cid, category FROM {contact} ORDER BY weight, category")->fetchAllKeyed();
+  $categories = db_select('contact', 'c')
+    ->addTag('translatable')
+    ->fields('c', array('cid', 'category'))
+    ->orderBy('weight')
+    ->orderBy('category')
+    ->execute()
+    ->fetchAllKeyed();
   $default_category = db_query("SELECT cid FROM {contact} WHERE selected = 1")->fetchField();
 
   // If there are no categories, do not display the form.
Index: modules/filter/filter.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.install,v
retrieving revision 1.22
diff -u -p -r1.22 filter.install
--- modules/filter/filter.install	13 Oct 2009 15:39:41 -0000	1.22
+++ modules/filter/filter.install	15 Oct 2009 04:53:53 -0000
@@ -76,6 +76,7 @@ function filter_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'Name of the text format (Filtered HTML).',
+        'translatable' => TRUE,
       ),
       'cache' => array(
         'type' => 'int',
Index: modules/filter/filter.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/filter/filter.module,v
retrieving revision 1.297
diff -u -p -r1.297 filter.module
--- modules/filter/filter.module	13 Oct 2009 15:39:41 -0000	1.297
+++ modules/filter/filter.module	15 Oct 2009 04:53:53 -0000
@@ -335,7 +335,12 @@ function filter_formats($account = NULL)
 
   // Statically cache all existing formats upfront.
   if (!isset($formats['all'])) {
-    $formats['all'] = db_query('SELECT * FROM {filter_format} ORDER BY weight')->fetchAllAssoc('format');
+    $formats['all'] = db_select('filter_format', 'ff')
+      ->addTag('translatable')
+      ->fields('ff')
+      ->orderBy('weight')
+      ->execute()
+      ->fetchAllAssoc('format');
   }
 
   // Build a list of user-specific formats.
Index: modules/menu/menu.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.install,v
retrieving revision 1.22
diff -u -p -r1.22 menu.install
--- modules/menu/menu.install	13 Oct 2009 18:36:25 -0000	1.22
+++ modules/menu/menu.install	15 Oct 2009 04:53:53 -0000
@@ -26,11 +26,13 @@ function menu_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'Menu title; displayed at top of block.',
+        'translatable' => TRUE,
       ),
       'description' => array(
         'type' => 'text',
         'not null' => FALSE,
         'description' => 'Menu description.',
+        'translatable' => TRUE,
       ),
     ),
     'primary key' => array('menu_name'),
Index: modules/menu/menu.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/menu/menu.module,v
retrieving revision 1.209
diff -u -p -r1.209 menu.module
--- modules/menu/menu.module	13 Oct 2009 01:24:07 -0000	1.209
+++ modules/menu/menu.module	15 Oct 2009 04:53:53 -0000
@@ -674,6 +674,7 @@ function menu_node_form_submit($form, &$
 function menu_get_menus($all = TRUE) {
   $system_menus = array_keys(menu_list_system_menus());
   $query = db_select('menu_custom');
+  $query->addTag('translatable');
   $query->addField('menu_custom', 'menu_name', 'menu_name');
   $query->addField('menu_custom', 'title', 'title');
   if (!$all) {
Index: modules/node/node.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.install,v
retrieving revision 1.33
diff -u -p -r1.33 node.install
--- modules/node/node.install	11 Oct 2009 03:07:18 -0000	1.33
+++ modules/node/node.install	15 Oct 2009 04:53:53 -0000
@@ -269,6 +269,7 @@ function node_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'translatable' => TRUE,
       ),
       'base' => array(
         'description' => 'The base string used to construct callbacks corresponding to this node type.',
@@ -281,12 +282,14 @@ function node_schema() {
         'type' => 'text',
         'not null' => TRUE,
         'size' => 'medium',
+        'translatable' => TRUE,
       ),
       'help' => array(
         'description' => 'Help information shown to the user when creating a {node} of this type.',
         'type' => 'text',
         'not null' => TRUE,
         'size' => 'medium',
+        'translatable' => TRUE,
       ),
       'has_title' => array(
         'description' => 'Boolean indicating whether this type uses the {node}.title field.',
@@ -301,6 +304,7 @@ function node_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'translatable' => TRUE,
       ),
       'has_body' => array(
         'description' => 'Boolean indicating whether this type has the body field attached.',
@@ -315,6 +319,7 @@ function node_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'translatable' => TRUE,
       ),
       'custom' => array(
         'description' => 'A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE).',
Index: modules/node/node.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/node/node.module,v
retrieving revision 1.1145
diff -u -p -r1.1145 node.module
--- modules/node/node.module	11 Oct 2009 03:07:18 -0000	1.1145
+++ modules/node/node.module	15 Oct 2009 04:53:53 -0000
@@ -671,9 +671,10 @@ function _node_types_build() {
     $_node_types->names[$type] = $info['name'];
   }
   $type_result = db_select('node_type', 'nt')
+    ->addTag('translatable')
+    ->addTag('node_type_access')
     ->fields('nt')
     ->orderBy('nt.type', 'ASC')
-    ->addTag('node_type_access')
     ->execute();
   foreach ($type_result as $type_object) {
     // Check for node types from disabled modules and mark their types for removal.
Index: modules/poll/poll.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.install,v
retrieving revision 1.26
diff -u -p -r1.26 poll.install
--- modules/poll/poll.install	29 Sep 2009 15:13:56 -0000	1.26
+++ modules/poll/poll.install	15 Oct 2009 04:53:53 -0000
@@ -62,6 +62,7 @@ function poll_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'The text for this choice.',
+        'translatable' => TRUE,
       ),
       'chvotes' => array(
         'type' => 'int',
Index: modules/poll/poll.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v
retrieving revision 1.317
diff -u -p -r1.317 poll.module
--- modules/poll/poll.module	11 Oct 2009 03:07:19 -0000	1.317
+++ modules/poll/poll.module	15 Oct 2009 04:53:53 -0000
@@ -438,7 +438,12 @@ function poll_load($nodes) {
     $poll = db_query("SELECT runtime, active FROM {poll} WHERE nid = :nid", array(':nid' => $node->nid))->fetchObject();
 
     // Load the appropriate choices into the $poll object.
-    $poll->choice = db_query("SELECT chid, chtext, chvotes, weight FROM {poll_choice} WHERE nid = :nid ORDER BY weight", array(':nid' => $node->nid))->fetchAllAssoc('chid', PDO::FETCH_ASSOC);
+    $poll->choice = db_select('poll_choice', 'c')
+      ->addTag('translatable')
+      ->fields('c', array('chid', 'chtext', 'chvotes', 'weight'))
+      ->condition('c', 'nid', $node->nid)
+      ->orderBy('weight')
+      ->fetchAllAssoc('chid', PDO::FETCH_ASSOC);
 
     // Determine whether or not this user is allowed to vote.
     $poll->allowvotes = FALSE;
Index: modules/poll/poll.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/poll/poll.pages.inc,v
retrieving revision 1.22
diff -u -p -r1.22 poll.pages.inc
--- modules/poll/poll.pages.inc	11 Oct 2009 03:07:19 -0000	1.22
+++ modules/poll/poll.pages.inc	15 Oct 2009 04:53:53 -0000
@@ -61,6 +61,7 @@ function poll_votes($node) {
   $select->join('poll_choice', 'pc', 'pv.chid = pc.chid');
   $select->join('users', 'u', 'pv.uid = u.uid');
   $queried_votes = $select
+    ->addTag('translatable')
     ->fields('pv', array('chid', 'uid', 'hostname', 'timestamp', 'nid'))
     ->fields('pc', array('chtext'))
     ->fields('u', array('name'))
Index: modules/system/system.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.install,v
retrieving revision 1.399
diff -u -p -r1.399 system.install
--- modules/system/system.install	14 Oct 2009 10:56:35 -0000	1.399
+++ modules/system/system.install	15 Oct 2009 04:53:53 -0000
@@ -568,6 +568,7 @@ function system_schema() {
         'type' => 'text',
         'not null' => TRUE,
         'size' => 'big',
+        'translatable' => TRUE,
       ),
     ),
     'primary key' => array('name'),
@@ -1155,11 +1156,13 @@ function system_schema() {
         'length' => 255,
         'not null' => TRUE,
         'default' => '',
+        'translatable' => TRUE,
       ),
       'options' => array(
         'description' => 'A serialized array of options to be passed to the url() or l() function, such as a query string or HTML attributes.',
         'type' => 'text',
         'not null' => FALSE,
+        'translatable' => TRUE,
       ),
       'module' => array(
         'description' => 'The name of the module that generated this link.',
Index: modules/taxonomy/taxonomy.install
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.install,v
retrieving revision 1.24
diff -u -p -r1.24 taxonomy.install
--- modules/taxonomy/taxonomy.install	8 Oct 2009 07:58:47 -0000	1.24
+++ modules/taxonomy/taxonomy.install	15 Oct 2009 04:53:53 -0000
@@ -41,12 +41,14 @@ function taxonomy_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'The term name.',
+        'translatable' => TRUE,
       ),
       'description' => array(
         'type' => 'text',
         'not null' => FALSE,
         'size' => 'big',
         'description' => 'A description of the term.',
+        'translatable' => TRUE,
       ),
       'weight' => array(
         'type' => 'int',
@@ -114,6 +116,7 @@ function taxonomy_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'The name of the synonym.',
+        'translatable' => TRUE,
       ),
     ),
     'indexes' => array(
@@ -141,6 +144,7 @@ function taxonomy_schema() {
         'not null' => TRUE,
         'default' => '',
         'description' => 'Name of the vocabulary.',
+        'translatable' => TRUE,
       ),
       'machine_name' => array(
         'type' => 'varchar',
@@ -154,6 +158,7 @@ function taxonomy_schema() {
         'not null' => FALSE,
         'size' => 'big',
         'description' => 'Description of the vocabulary.',
+        'translatable' => TRUE,
       ),
       'relations' => array(
         'type' => 'int',
Index: modules/taxonomy/taxonomy.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.module,v
retrieving revision 1.518
diff -u -p -r1.518 taxonomy.module
--- modules/taxonomy/taxonomy.module	14 Oct 2009 20:22:04 -0000	1.518
+++ modules/taxonomy/taxonomy.module	15 Oct 2009 05:55:04 -0000
@@ -618,9 +618,9 @@ function taxonomy_get_parents($tid, $key
   if ($tid) {
     $query = db_select('taxonomy_term_data', 't');
     $query->join('taxonomy_term_hierarchy', 'h', 'h.parent = t.tid');
-    $query->addTag('term_access');
-
     $result = $query
+      ->addTag('translatable')
+      ->addTag('term_access')
       ->fields('t')
       ->condition('h.tid', $tid)
       ->orderBy('weight')
@@ -659,9 +659,9 @@ function taxonomy_get_parents_all($tid) 
 function taxonomy_get_children($tid, $vid = 0, $key = 'tid') {
   $query = db_select('taxonomy_term_data', 't');
   $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
-  $query->addTag('term_access');
-
   $query
+    ->addTag('translatable')
+    ->addTag('term_access')
     ->fields('t')
     ->condition('parent', $tid)
     ->orderBy('weight')
@@ -712,9 +712,9 @@ function taxonomy_get_tree($vid, $parent
 
     $query = db_select('taxonomy_term_data', 't');
     $query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
-    $query->addTag('term_access');
-
     $result = $query
+      ->addTag('translatable')
+      ->addTag('term_access')
       ->fields('t')
       ->fields('h', array('parent'))
       ->condition('t.vid', $vid)
@@ -752,8 +752,11 @@ function taxonomy_get_tree($vid, $parent
  */
 function taxonomy_get_synonyms($tid) {
   if ($tid) {
-    $synonyms = array();
-    return db_query('SELECT name FROM {taxonomy_term_synonym} WHERE tid = :tid', array(':tid' => $tid))->fetchCol();
+    return db_select('taxonomy_term_synonym')
+      ->addTag('translatable')
+      ->fields(array('name'))
+      ->condition('tid', $tid)
+      ->fetchCol();
   }
   else {
     return array();
@@ -772,7 +775,15 @@ function taxonomy_get_synonym_root($syno
   $synonyms = &drupal_static(__FUNCTION__, array());
 
   if (!isset($synonyms[$synonym])) {
-    $synonyms[$synonym] = db_query("SELECT * FROM {taxonomy_term_synonym} s, {taxonomy_term_data} t WHERE t.tid = s.tid AND s.name = :name", array(':name' => $synonym))->fetch();
+    $query = db_select('taxonomy_term_synonym', 's');
+    $query->join('taxonomy_term_data', 't', 't.tid = s.tid');
+    $synonyms[$synonym] = $query
+      ->addTag('translatable')
+      ->addTag('term_access')
+      ->fields('s')
+      ->fields('t')
+      ->condition('s.name', $synonym)
+      ->fetch();
   }
   return $synonyms[$synonym];
 }
@@ -811,6 +822,8 @@ class TaxonomyTermController extends Dru
 
   protected function buildQuery() {
     parent::buildQuery();
+    $this->query->addTag('translatable');
+    $this->query->addTag('term_access');
     // When name is passed as a condition use LIKE.
     if (isset($this->conditions['name'])) {
       $conditions = &$this->query->conditions();
@@ -848,6 +861,7 @@ class TaxonomyTermController extends Dru
 class TaxonomyVocabularyController extends DrupalDefaultEntityController {
   protected function buildQuery() {
     parent::buildQuery();
+    $this->query->addTag('translatable');
     $this->query->orderBy('base.weight');
     $this->query->orderBy('base.name');
   }
@@ -1207,6 +1221,7 @@ function taxonomy_field_load($obj_type, 
     $query = db_select('taxonomy_term_data', 't');
     $query->fields('t');
     $query->condition('t.tid', $tids, 'IN');
+    $query->addTag('translatable');
     $query->addTag('term_access');
     $terms = $query->execute()->fetchAllAssoc('tid');
 
Index: modules/taxonomy/taxonomy.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.pages.inc,v
retrieving revision 1.38
diff -u -p -r1.38 taxonomy.pages.inc
--- modules/taxonomy/taxonomy.pages.inc	9 Oct 2009 01:00:06 -0000	1.38
+++ modules/taxonomy/taxonomy.pages.inc	15 Oct 2009 04:53:53 -0000
@@ -108,6 +108,7 @@ function taxonomy_autocomplete($field_na
     }
 
     $query = db_select('taxonomy_term_data', 't');
+    $query->addTag('translatable');
     $query->addTag('term_access');
 
     // Do not select already entered terms.
