Index: i18n.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n.inc,v
retrieving revision 1.3
diff -u -r1.3 i18n.inc
--- i18n.inc	6 Apr 2004 19:40:37 -0000	1.3
+++ i18n.inc	23 Jul 2004 12:45:31 -0000
@@ -7,60 +7,59 @@
  */
 
 function conf_url_rewrite($path, $mode = 'incoming') {
-		if(variable_get('i18n_keep','')=='url' || variable_get('i18n_content',0)){
-			 return i18n_url_rewrite($path,$mode);
-		} else {
-			return $path;
-		}
+  if(variable_get('i18n_keep','')=='url' || variable_get('i18n_content',0)){
+    return i18n_url_rewrite($path,$mode);
+  } else {
+    return $path;
+  }
 } 
 
 function i18n_url_rewrite($path, $mode = 'incoming') {
-	global $i18n_langpath;
+  global $i18n_langpath;
   if ($mode == 'incoming') { // URL coming from a client
-			if($i18n_langpath=i18n_get_lang_prefix($path)){
-				// Remove language from path and try to find alias for new path
-				$path=substr($path,3);
-				return drupal_get_normal_path($path);
-			} else {
-				return $path;
-			}
-
+    if($i18n_langpath=i18n_get_lang_prefix($path)){
+      // Remove language from path and try to find alias for new path
+      $path=substr($path,3);
+      return drupal_get_normal_path($path);
+    } else {
+      return $path;
+    }
   }
   else { // URL going out to a client
-  	if($i18n_langpath){
-  		return "$i18n_langpath/$path";
-  	} else {
-  		return $path;
-  	}
+    if($i18n_langpath){
+      return "$i18n_langpath/$path";
+    } else {
+      return $path;
+    }
   }
 }
 
 // Get language from path, but only if it is in the $languages array
 function i18n_get_lang_prefix($path){
-	global $languages;
-	$split=split("/",$path);
-	$maybelang=$split[0];
-	if($languages[$maybelang]){
-		return $maybelang;
-	}
+  global $languages;
+  $split=split("/",$path);
+  $maybelang=$split[0];
+  if($languages[$maybelang]){
+    return $maybelang;
+  }
 }
 
 // This is just an experiment to keep tables in sync. 
 // Needs some patching to core.
 function i18n_db_sync($query){
-	global $languages,$i18n_lang;
-	global $i18n_db_sync,$db_prefix_i18n_sync;
-	if (preg_match("/^(insert into|delete from)[ ]+\{([\w]+)\}.*/i",$query,$matches) && $db_prefix_i18n_sync[$matches[2]]){
-		debug("SYNC:".$sql);
-		$i18n_db_sync=false;
-		foreach($languages as $lang => $desc){
-				i18n_set_db_prefix($lang);
-				$result[$lang]=_db_query(db_prefix($args));
-		}
-		i18n_set_db_prefix($locale);
-		$i18n_db_sync=true;
-	} elseif(preg_match("/^REPLACE INTO \{sequences\}.*/i",$sql)){
-	
-	}
+  global $languages,$i18n_lang;
+  global $i18n_db_sync,$db_prefix_i18n_sync;
+  if (preg_match("/^(insert into|delete from)[ ]+\{([\w]+)\}.*/i",$query,$matches) && $db_prefix_i18n_sync[$matches[2]]){
+    debug("SYNC:".$sql);
+    $i18n_db_sync=false;
+    foreach($languages as $lang => $desc){
+      i18n_set_db_prefix($lang);
+      $result[$lang]=_db_query(db_prefix($args));
+    }
+    i18n_set_db_prefix($locale);
+    $i18n_db_sync=true;
+  } 
+  elseif(preg_match("/^REPLACE INTO \{sequences\}.*/i",$sql)){
+  }
 }
 ?>
\ No newline at end of file
Index: i18n.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/i18n/i18n.module,v
retrieving revision 1.5
diff -u -r1.5 i18n.module
--- i18n.module	6 Apr 2004 19:40:37 -0000	1.5
+++ i18n.module	23 Jul 2004 12:45:31 -0000
@@ -7,31 +7,30 @@
  */
 
 /**
- *	Common module functions
+ *  Common module functions
  */
 
-// This runs after user has ben initialized and path may be already translated
-
+// This runs after user has been initialized and path may be already translated
 function i18n_init(){
-	global $i18n_langpath;
+  global $i18n_langpath;
 
-	// Quick fix, check if called from bootstrap.inc
-	if(!function_exists("drupal_get_path_map")) return 0;
-	
-	if($lang=i18n_get_lang()){
-		i18n_set_lang($lang);
-	}else{
-  	$lang= i18n_get_default_lang();
-	}
+  // Quick fix, check if called from bootstrap.inc
+  if(!function_exists("drupal_get_path_map")) return 0;
+  
+  if($lang=i18n_get_lang()){
+    i18n_set_lang($lang);
+  }else{
+    $lang= i18n_get_default_lang();
+  }
   
   if(variable_get("i18n_content",0)){
-  	i18n_set_db_prefix($lang);
- 		$original=i18n_get_original_path();
-  	if(!$i18n_langpath && $trpath=i18n_get_normal_path("$lang/$original")){
-  		$_GET["q"]=$trpath;
-  	}elseif(!$original || $i18n_langpath==$original){
-			$_GET["q"]=drupal_get_normal_path(i18n_front_page($lang));
-  	}
+    i18n_set_db_prefix($lang);
+     $original=i18n_get_original_path();
+    if(!$i18n_langpath && $trpath=i18n_get_normal_path("$lang/$original")){
+      $_GET["q"]=$trpath;
+    }elseif(!$original || $i18n_langpath==$original){
+      $_GET["q"]=drupal_get_normal_path(i18n_front_page($lang));
+    }
   }
   
   if(variable_get("i18n_interface",0)) i18n_set_default_lang($lang);
@@ -39,59 +38,80 @@
 }
 
 function i18n_set_db_prefix($lang){
-	global $db_prefix,$db_prefix_i18n;
-	if(is_array($db_prefix_i18n)){
-		$db_prefix=array_merge($db_prefix,str_replace('**',$lang,$db_prefix_i18n));
-	}
+  global $db_prefix,$db_prefix_i18n;
+  if(is_array($db_prefix_i18n)){
+    $db_prefix=array_merge($db_prefix,str_replace('**',$lang,$db_prefix_i18n));
+  }
 }
 
 function i18n_front_page($lang){
-	return variable_get("i18n_front_page",0) ? $lang.'/'.variable_get('site_frontpage','node') : variable_get('site_frontpage','node');
+  return variable_get("i18n_front_page",0) ? $lang.'/'.variable_get('site_frontpage','node') : variable_get('site_frontpage','node');
 }
 
 function i18n_help($section = "admin/help#i18n") {
   switch ($section) {
-  	case "admin/help#i18n":
-  		$output = t("
-  			<p>This module provides support for internationalization of Drupal sites in various ways:</p>
-  			<ul><li>Translation of the user interface for registered and anonymous users</li>
-  			<li>Multi-language for content, combined with url aliasing. For this feature to be used, you must enable it in the module configuration and then use url aliasing to keep pages in various languages. I.e. 'en/mypage', 'es/mypage' should be English and Spanish versions of the same page</li>
-  			<li>Detection of the brower language</li>
-  			<li>Keeps the language settings accross consecutive requests, using a number of methods: URL rewriting, sessions, cookies</li>
-  			<li>Provides a block for language selection and two theme functions: <i>i18n_flags</i> and <i>i18n_links</i></li></ul>
-  			<p>For url rewriting you need to have the file <b>i18n.inc</b> in the <i>includes</i> folder and add the following line to your configuration file:</p>
-  			<pre>
-  			include 'includes/i18n.inc';
-  			</pre>
-  			<p>You can try different settings to have only content translation, interface translation or both.</p>
-  			<p><small>Module developed by <a href=\"http://freelance.reyero.net\">freelance.reyero.net</a></small></p>");
-  		break;
-    case "admin/system/modules#description":
+    case "admin/help#i18n":
+      $output = t("
+        <p>This module provides support for internationalization of Drupal sites in various ways:</p>
+        <ul><li>Translation of the user interface for registered and anonymous users</li>
+        <li>Multi-language for content, combined with url aliasing. For this feature to be used, you must enable it in the module configuration and then use url aliasing to keep pages in various languages. I.e. 'en/mypage', 'es/mypage' should be English and Spanish versions of the same page</li>
+        <li>Detection of the brower language</li>
+        <li>Keeps the language settings accross consecutive requests, using a number of methods: URL rewriting, sessions, cookies</li>
+        <li>Provides a block for language selection and two theme functions: <i>i18n_flags</i> and <i>i18n_links</i></li></ul>
+        <p>For url rewriting you need to have the file <b>i18n.inc</b> in the <i>includes</i> folder and add the following line to your configuration file:</p>
+        <pre>
+        include 'includes/i18n.inc';
+        </pre>
+        <p>You can try different settings to have only content translation, interface translation or both.</p>
+        <p><small>Module developed by <a href=\"http://freelance.reyero.net\">freelance.reyero.net</a></small></p>");
+      break;
+    case "admin/modules#description":
       $output = t("Supports site internationalization (i18n).");
       break;
   }
   return $output;
 }
 
+function i18n_menu() {
+  global $languages,$i18n_lang;  
+  
+  if (arg(0) == 'node' && is_numeric(arg(1)) && variable_get("i18n_content",0)) {
+    foreach ($languages as $lang => $desc) {
+      if ($lang == i18n_get_lang()) {
+        $type = MENU_DEFAULT_LOCAL_TASK;
+      }
+      else {
+        $type = MENU_LOCAL_TASK;
+      }
+      
+      $items[] = array('path' => 'node/'. arg(1) .'/edit/'.$lang, 'title' => t('edit %language',array('%language'=>$lang)),
+        'callback' => 'i18n_node_admin',
+        'access' => user_access('administer nodes'),
+        'type' => $type);
+    }
+  }
+  return $items;
+}
+
 function i18n_settings(){
-	$output .= form_radios(t("Interface translation"),"i18n_interface",variable_get("i18n_interface",0),array(t("Disabled"),t("Enabled")),t("If disabled, uses Drupal's default. If enabled, translates the interface to selected language"));
-	$output .= form_radios(t("Content translation"),"i18n_content",variable_get("i18n_content",0),array(t("Disabled"),t("Enabled")),t("If enabled, prepends language code to url and searches for translated content"));
-	$output .= form_group(t("Synchronize content")." <strong>EXPERIMENTAL FEATURE</strong>"
-		,form_checkbox(t("Nodes"),"i18n_sync_nodes",1,variable_get("i18n_sync_nodes",0))
-		.form_checkbox(t("Taxonomy"),"i18n_sync_taxonomy",1,variable_get("i18n_sync_taxonomy",0))
-		,t("Synchronize tables for different languages. When some element is created/removed, it will be created/removed for all languages with the same id")
-		);
-	$output .= form_select(t("Front page"),"i18n_front_page",variable_get("i18n_front_page",0),array(t("Default"),t("Language dependant")),t("If language dependant and <i>Content translation</i> is enabled, default front page will be prepended with language code, i.e. 'en/node'"));
-	$output .=form_radios(t("Keep Language"),"i18n_keep",variable_get("i18n_keep",'url'),
-	array(	""=>t("Disabled"),
-					"url" => t("URL rewriting"),
-					"session" => t("Session"),
-					"cookie" => t("Cookie")
-	),t("A language code independent of user's language will be kept accross requests using the selected method"));
-	$output .= form_radios(t("Detect browser language"),"i18n_browser",variable_get("i18n_browser",0),array(t("Disabled"),t("Enabled")));
-	$output .= form_textfield(t("Flags directory"),"i18n_flags",variable_get("i18n_flags","modules/i18n/flags/*.gif"),70,180,t("Path for flags. Asterisk '*' is a placeholder for language code. This is only needed when you want a language selector block"));
+  $output .= form_radios(t("Interface translation"),"i18n_interface",variable_get("i18n_interface",0),array(t("Disabled"),t("Enabled")),t("If disabled, uses Drupal's default. If enabled, translates the interface to selected language"));
+  $output .= form_radios(t("Content translation"),"i18n_content",variable_get("i18n_content",0),array(t("Disabled"),t("Enabled")),t("If enabled, prepends language code to url and searches for translated content"));
+  $output .= form_group(t("Synchronize content")." <strong>EXPERIMENTAL FEATURE</strong>"
+    ,form_checkbox(t("Nodes"),"i18n_sync_nodes",1,variable_get("i18n_sync_nodes",0))
+    .form_checkbox(t("Taxonomy"),"i18n_sync_taxonomy",1,variable_get("i18n_sync_taxonomy",0))
+    ,t("Synchronize tables for different languages. When some element is created/removed, it will be created/removed for all languages with the same id")
+    );
+  $output .= form_select(t("Front page"),"i18n_front_page",variable_get("i18n_front_page",0),array(t("Default"),t("Language dependant")),t("If language dependant and <i>Content translation</i> is enabled, default front page will be prepended with language code, i.e. 'en/node'"));
+  $output .=form_radios(t("Keep Language"),"i18n_keep",variable_get("i18n_keep",'url'),
+  array(  ""=>t("Disabled"),
+          "url" => t("URL rewriting"),
+          "session" => t("Session"),
+          "cookie" => t("Cookie")
+  ),t("A language code independent of user's language will be kept accross requests using the selected method"));
+  $output .= form_radios(t("Detect browser language"),"i18n_browser",variable_get("i18n_browser",0),array(t("Disabled"),t("Enabled")));
+  $output .= form_textfield(t("Flags directory"),"i18n_flags",variable_get("i18n_flags","modules/i18n/flags/*.gif"),70,180,t("Path for flags. Asterisk '*' is a placeholder for language code. This is only needed when you want a language selector block"));
 
-	return $output;
+  return $output;
 }
 
 function i18n_block($op = 'list', $delta = 0) {
@@ -99,10 +119,10 @@
     $blocks[0]['info'] = t('Languages');
   }
   else {
-  	$blocks['subject']=t('Languages');
-  	$content = "<table><tr><td>";
-  	$content .=  theme("i18n_links",1,1,"</td><td>","</td></tr><tr><td>");
-  	$content .= "</td></tr></table>";
+    $blocks['subject']=t('Languages');
+    $content = "<table><tr><td>";
+    $content .=  theme("i18n_links",1,1,"</td><td>","</td></tr><tr><td>");
+    $content .= "</td></tr></table>";
     $blocks['content'] =$content;
   }
 
@@ -116,87 +136,94 @@
  
 if(!function_exists("i18n_get_lang_prefix")){
 function i18n_get_lang_prefix($path){
-	global $languages;
-	$split=split("/",$path);
-	$maybelang=$split[0];
-	if($languages[$maybelang]){
-		return $maybelang;
-	}
+  global $languages;
+  $split=split("/",$path);
+  $maybelang=$split[0];
+  if($languages[$maybelang]){
+    return $maybelang;
+  }
 }
 }
  
 function i18n_get_lang(){
-	global $i18n_lang;
-	if($i18n_lang){
-		return $i18n_lang;
-	} elseif($lang=$_GET['i18n_lang']) {
-		return $i18n_lang=$lang;
-	} else {
-		switch(variable_get('i18n_keep','')){
-			case 'url': // URL
-				$lang= i18n_get_lang_prefix(i18n_get_original_path());
-				break;
-			case 'session': // Session
-				session_start();
-				$lang = $_SESSION['i18n_lang'];
-				break;
-			case 'cookie': // Cookie
-				$lang=$_COOKIE['i18n_lang'];
-				break;
-			default:
-				$lang=$_GET['i18n_lang'];
-		}
-	}
-	return $i18n_lang=$lang;
+  global $i18n_lang;
+
+  //see if the language is already set AND if the url does not contain a swithch.
+  if($i18n_lang && !$_GET['i18n_lang']){
+    return $i18n_lang;
+  }
+  //see if the url contains a language preference. if so, language switch.
+  elseif($lang=$_GET['i18n_lang']) {
+    return $i18n_lang=$lang;
+  }
+  //otherwise, look for the preferred method of getting a language
+  else {
+    switch(variable_get('i18n_keep','')){
+      case 'url': // URL
+        $lang= i18n_get_lang_prefix(i18n_get_original_path());
+        break;
+      case 'session': // Session
+        session_start();
+        $lang = $_SESSION['i18n_lang'];
+        break;
+      case 'cookie': // Cookie
+        $lang=$_COOKIE['i18n_lang'];
+        break;
+      default:
+        $lang=$_GET['i18n_lang'];
+    }
+  }
+  return $i18n_lang=$lang;
 }
 
 function i18n_set_lang($lang){
-	global $i18n_lang;
-	global $i18n_langpath;
-	$i18n_lang=$lang;
-	switch(variable_get('i18n_keep','')){
-		case 'url': // URL
-		case 'query': // Query string
-			$i18n_langpath=$lang;
-			break;
-		case 'session': // Session
-			session_start();
-			$_SESSION["i18n_lang"]=$lang;
-			break;
-		case 'cookie': // Cookie
-			setcookie('i18n_lang',$lang,NULL,'/');
-			break;
-	}
+  global $i18n_lang;
+  global $i18n_langpath;
+
+  $i18n_lang=$lang;
+  switch(variable_get('i18n_keep','')){
+    case 'url': // URL
+    case 'query': // Query string
+      $i18n_langpath=$lang;
+      break;
+    case 'session': // Session
+      session_start();
+      $_SESSION["i18n_lang"]=$lang;
+      break;
+    case 'cookie': // Cookie
+      setcookie('i18n_lang',$lang,NULL,'/');
+      break;
+  }
 }
 
 function i18n_get_default_lang(){
-	global $user;
-	global $languages;
-	if(!$lang=$user->language){
-  	if(variable_get('i18n_browser',0) && $lang=i18n_get_browser_lang()){
-  		i18n_set_default_lang($lang);
-  	} else {
-  		$lang=key($languages);
-  		reset($languages);
-  	}
-	}
-	return $lang;	
+  global $user;
+  global $languages;
+  if(!$lang=$user->language){
+    if(variable_get('i18n_browser',0) && $lang=i18n_get_browser_lang()){
+      i18n_set_default_lang($lang);
+    } else {
+      $lang=key($languages);
+      reset($languages);
+    }
+  }
+  return $lang;  
 }
 
 // Set language as default rearranging $languages array
 function i18n_set_default_lang($lang){
-	global $languages;
-	global $i18n_lang;
-	$i18n_lang=$lang;
-	if(variable_get("i18n_interface",0)){
-		$deflang=key($languages);
-		if($lang != $deflang){ 
-			// Reorder $languages to set $lang as the first element...
-			$languages=array_merge(array($lang => $languages[$lang]),$languages);
-		} else { //Language is the default
-				reset($languages);
-		}
-	}
+  global $languages;
+  global $i18n_lang;
+  $i18n_lang=$lang;
+  if(variable_get("i18n_interface",0)){
+    $deflang=key($languages);
+    if($lang != $deflang){ 
+      // Reorder $languages to set $lang as the first element...
+      $languages=array_merge(array($lang => $languages[$lang]),$languages);
+    } else { //Language is the default
+        reset($languages);
+    }
+  }
 }
 
 // Function based on common.inc::drupal_get_normal_path, but returns nothing if mapping not found
@@ -209,83 +236,91 @@
 // To get the original path. Cannot use $_GET["q"] cause it may have been already changed
 function i18n_get_original_path(){
   $path=$_REQUEST["q"];
-	return trim($path,"/");
+  return trim($path,"/");
 }
 
 // Get language from browser settings, but only if it is in the $languages array
 function i18n_get_browser_lang(){
-	global $languages;
-	$accept=explode(",",array_shift( explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"])));
-	foreach($accept as $lang){
-		$lang=substr($lang,0,2);
-		if($languages[$lang]) return $lang;
-	}
+  global $languages;
+  $accept=explode(",",array_shift( explode(";",$_SERVER["HTTP_ACCEPT_LANGUAGE"])));
+  foreach($accept as $lang){
+    $lang=substr($lang,0,2);
+    if($languages[$lang]) return $lang;
+  }
 }
 
 /**
- *	Theme functions
+ *  Theme functions
  */
  
 /**
-	* Returns language links with optional flags
-	*
-	* @param $flags an integer, 1 to use language flags
-	* @param $names an integer, 1 to use language names
-	* @param $delim1 delimiter to place between language name and flag
-	* @param $delim2 delimiter to place between different languages
-	*
-	* @return a string containing the @a links output.
-	*/
-	
+  * Returns language links with optional flags
+  *
+  * @param $flags an integer, 1 to use language flags
+  * @param $names an integer, 1 to use language names
+  * @param $delim1 delimiter to place between language name and flag
+  * @param $delim2 delimiter to place between different languages
+  *
+  * @return a string containing the @a links output.
+  */
+  
 function theme_i18n_links($flags=1,$names=1,$delim1=" ",$delim2=" "){
-	global $languages;
-	global $i18n_lang;
-
-	foreach($languages as $lang => $langname){
-		$name= $names ? t($langname): ""; // Should be localized??
-		$flag= $flags ? _i18n_flag($lang) :"";
-		if($lang==$i18n_lang){
-			$links[] = "<strong>$name</strong>$delim1$flag";
-		}else {
-			$links[] = i18n_l($name,$lang).$delim1.i18n_l($flag,$lang);
-		}
-	}
-	$output =implode($delim2,$links);
-	return $output;	
+  global $languages;
+  global $i18n_lang;
+  
+  foreach($languages as $lang => $langname){
+    $name= $names ? t($langname): ""; // Should be localized??
+    $flag= $flags ? _i18n_flag($lang) :"";
+    if($lang==$i18n_lang){
+      $links[] = "<strong>$name</strong>$delim1$flag";
+    }else {
+      $links[] = i18n_l($name,$lang).$delim1.i18n_l($flag,$lang);
+    }
+  }
+  $output =implode($delim2,$links);
+  return $output;  
 }
 
 function theme_i18n_flags(){
-	return theme_i18n_links(1,0);
+  return theme_i18n_links(1,0);
 }
 
 function _i18n_flag($lang,$attribs=array()){
-	if($path=variable_get("i18n_flags","modules/i18n/flags/*.gif")){
-		$flag=str_replace("*",$lang,$path);
-		return "<img class=\"i18n\" src=\"$flag\"".drupal_attributes($attribs)." />";
-	}
+  if($path=variable_get("i18n_flags","modules/i18n/flags/*.gif")){
+    $flag=str_replace("*",$lang,$path);
+    return "<img class=\"i18n\" src=\"$flag\"".drupal_attributes($attribs)." />";
+  }
 }
 
 // Creates links for different languages
 function i18n_l($text, $lang , $url="",$attributes=array(),$query=NULL) {
-	global $i18n_langpath;
-	// If !url get from original request
-	if(!$url) $url=i18n_get_original_path();
-		// If url has lang_prefix, remove it
-	if(i18n_get_lang_prefix($url)) $url=substr($url,3);
-	
-	if(variable_get('i18n_keep','')=='url'){
-		$url="$lang/$url";
-	} else {
-		if(variable_get('i18n_content',0)) $url="$lang/$url";
-		$query= $query ? $query.'&i18n_lang='.$lang : "i18n_lang=$lang";
-	}
-	// Save $i18n_langpath, and set to null to avoid url_rewriting
-	$tmp=$i18n_langpath;
-	$i18n_langpath="";
-	$result= l($text,$url,$attributes,$query);
-	// Restore $i18n_langpath
-	$i18n_langpath=$tmp;	
-	return $result;
+  global $i18n_langpath;
+  
+  // If !url get from original request
+  if(!$url) $url=i18n_get_original_path();
+    // If url has lang_prefix, remove it
+  if(i18n_get_lang_prefix($url)) $url=substr($url,3);
+  
+  if(variable_get('i18n_keep','')=='url'){
+    $url="$lang/$url";
+  } else {
+    //if(variable_get('i18n_content',0)) $url="$lang/$url";
+    $query= $query ? $query.'&i18n_lang='.$lang : "i18n_lang=$lang";
+  }
+  // Save $i18n_langpath, and set to null to avoid url_rewriting
+  $tmp=$i18n_langpath;
+  $i18n_langpath="";
+  $result= l($text,$url,$attributes,$query);
+  // Restore $i18n_langpath
+  $i18n_langpath=$tmp;  
+  return $result;
+}
+
+// Changes the language of the node admin
+function i18n_node_admin () {
+  $lang = arg(3);
+  i18n_set_db_prefix($lang);
+  node_page();
 }
 
 // TODO: Check for other node's tables... ???
@@ -293,106 +328,106 @@
 function i18n_nodeapi(&$node, $op, $arg = 0) {
   global $i18n_lang,$db_prefix_i18n;
 
-	if(variable_get('i18n_sync_nodes',0) && $db_prefix_i18n['node']){
-	  switch ($op) {
-	  case 'insert':
-	    $fields = node_invoke_nodeapi($node, "fields");
-	
-	    // Prepare the query:
-	    foreach ($node as $key => $value) {
-	      if (in_array($key, $fields)) {
-	        $k[] = check_query($key);
-	        $v[] = $value;
-	        $s[] = "'%s'";
-	      }
-	    }
-	    // Insert copies for each language
-	    i18n_foreach_lang("sync_node_insert",$k,$s,$v);
-	    break;
-	
-	  case 'delete':
-	  	i18n_foreach_lang("sync_node_delete",$node->nid);
-			break;
-	  }
-	}
+  if(variable_get('i18n_sync_nodes',0) && $db_prefix_i18n['node']){
+    switch ($op) {
+    case 'insert':
+      $fields = node_invoke_nodeapi($node, "fields");
+  
+      // Prepare the query:
+      foreach ($node as $key => $value) {
+        if (in_array($key, $fields)) {
+          $k[] = check_query($key);
+          $v[] = $value;
+          $s[] = "'%s'";
+        }
+      }
+      // Insert copies for each language
+      i18n_foreach_lang("sync_node_insert",$k,$s,$v);
+      break;
+  
+    case 'delete':
+      i18n_foreach_lang("sync_node_delete",$node->nid);
+      break;
+    }
+  }
 }
 
 function i18n_sync_node_insert($lang,$k,$s,$v){
-	db_next_id("{node}_nid");
-	db_query("INSERT INTO {node} (". implode(", ", $k) .") VALUES(". implode(", ", $s) .")", $v);
+  db_next_id("{node}_nid");
+  db_query("INSERT INTO {node} (". implode(", ", $k) .") VALUES(". implode(", ", $s) .")", $v);
 }
 
 function i18n_sync_node_delete($lang,$nid){
-	db_query("DELETE FROM {node} WHERE nid='%s'", $nid);
+  db_query("DELETE FROM {node} WHERE nid='%s'", $nid);
 }
 
 function i18n_taxonomy($op,$type,$object){
-	if(variable_get("i18n_sync_taxonomy",0) 
-		&& function_exists("i18n_sync_${type}_${op}")) {
-			i18n_foreach_lang("sync_${type}_${op}",$object);	
-	}
+  if(variable_get("i18n_sync_taxonomy",0) 
+    && function_exists("i18n_sync_${type}_${op}")) {
+      i18n_foreach_lang("sync_${type}_${op}",$object);  
+  }
 }
 
 function i18n_sync_vocabulary_insert($lang,$vocabulary){
-	$data=$vocabulary;
-	// Should check wheteher vid already exists
+  $data=$vocabulary;
+  // Should check wheteher vid already exists
   db_next_id("{vocabulary}_vid");
   db_query("INSERT INTO {vocabulary} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
 }
 
 function i18n_sync_vocabulary_delete($lang,$vocabulary){
-	$vid=$vocabulary->vid;
+  $vid=$vocabulary->vid;
   db_query("DELETE FROM {vocabulary} WHERE vid = %d", $vid);
   $result = db_query("SELECT tid FROM {term_data} WHERE vid = %d", $vid);
   while ($term = db_fetch_object($result)) {
     i18n_sync_term_delete($lang,$term);
-  }	
+  }  
 }
 
 function i18n_sync_term_insert($lang,$edit){
-	// Should check whether tid already exists
+  // Should check whether tid already exists
   db_next_id("{term_data}_tid");
   $data = array("tid" => $edit["tid"], "name" => $edit["name"], "description" => $edit["description"], "vid" => $edit["vid"], "weight" => $edit["weight"]);
   db_query("INSERT INTO {term_data} ". _prepare_insert($data, 1) ." VALUES ". _prepare_insert($data, 2));
- 	
+   
 }
 
 function i18n_sync_term_delete($lang,$term){
-	// TODO: Check tables in db_prefix_i18n ? It won't hurt if data is deleted twice
-	$tid=$term->tid;
+  // TODO: Check tables in db_prefix_i18n ? It won't hurt if data is deleted twice
+  $tid=$term->tid;
   db_query("DELETE FROM {term_data} WHERE tid = %d", $tid);
   db_query("DELETE FROM {term_hierarchy} WHERE tid = %d", $tid);
   db_query("DELETE FROM {term_relation} WHERE tid1 = %d OR tid2 = %d", $tid, $tid);
   db_query("DELETE FROM {term_synonym} WHERE tid = %d", $tid);
   // TODO: What if sync taxonomy but no nodes, should think abt it...
   db_query("DELETE FROM {term_node} WHERE tid = %d", $tid);
-	
+  
 }
 
 function i18n_foreach_lang($callback){
-	global $languages,$i18n_lang;
-	$args=func_get_args();
-	foreach ($languages as $lang => $desc) {
-	  if ($lang != $i18n_lang) {
-	  	$args[0]=$lang;
-	  	i18n_set_db_prefix($lang);
-			call_user_func_array("i18n_$callback",$args);
-	  }
-	}
-	i18n_set_db_prefix($i18n_lang);
+  global $languages,$i18n_lang;
+  $args=func_get_args();
+  foreach ($languages as $lang => $desc) {
+    if ($lang != $i18n_lang) {
+      $args[0]=$lang;
+      i18n_set_db_prefix($lang);
+      call_user_func_array("i18n_$callback",$args);
+    }
+  }
+  i18n_set_db_prefix($i18n_lang);
 }
 
 function i18n_get_table($table,$lang){
-	global $i18n_db_prefix;
-	if($db_prefix_i18n[$table]) {
-		return str_replace('**',$lang,$db_prefix_i18n[$table]).$table;
-	} elseif(is_array($db_prefix_i18n)){
-		return str_replace('**',$lang,$db_prefix_i18n['default']).$table;
-	} elseif(is_string($db_prefix_i18n)){
-		return str_replace('**',$lang,$db_prefix_i18n).$table;
-	} else {
-		return $table;
-	}
+  global $i18n_db_prefix;
+  if($db_prefix_i18n[$table]) {
+    return str_replace('**',$lang,$db_prefix_i18n[$table]).$table;
+  } elseif(is_array($db_prefix_i18n)){
+    return str_replace('**',$lang,$db_prefix_i18n['default']).$table;
+  } elseif(is_string($db_prefix_i18n)){
+    return str_replace('**',$lang,$db_prefix_i18n).$table;
+  } else {
+    return $table;
+  }
 }
 
 
