Index: nodewords.module
===================================================================
RCS file: /var/lib/cvs/rr.realradios.com/sites/all/modules/contrib/nodewords/nodewords.module,v
retrieving revision 1.1
diff -u -p -r1.1 nodewords.module
--- nodewords.module	23 Sep 2008 12:24:36 -0000	1.1
+++ nodewords.module	26 Feb 2009 12:16:06 -0000
@@ -397,13 +397,13 @@ function nodewords_get($type = NULL, $id
 /**
  * Update or insert tags in the table
  */
-function _nodewords_set($type, $id, $tags) {
+function _nodewords_set($type, $id, $tags, $language_code = '') {
   foreach ($tags as $name => $content) {
     if (empty($content)) {
-      _nodewords_delete_tag($type, $id, $name);
+      _nodewords_delete_tag($type, $id, $name, $language_code);
     }
     else {
-      _nodewords_update_tag($type, $id, $name, $content);
+      _nodewords_update_tag($type, $id, $name, $content, $language_code);
     }
   }
 }
@@ -411,16 +411,17 @@ function _nodewords_set($type, $id, $tag
 /**
  * Delete tags from table
  */
-function _nodewords_delete($type, $id) {
-  return db_query("DELETE FROM {nodewords} WHERE type = '%s' AND id = '%s'", $type, $id);
+function _nodewords_delete($type, $id, $language_code = '') {
+  return db_query("DELETE FROM {nodewords} WHERE type = '%s' AND id = '%s' AND language_code = '%s'", $type, $id, $language_code);
 }
 
 /**
  * Load tags from table
  */
-function _nodewords_load($type, $id) {
+function _nodewords_load($type, $id, $language_code = '') {
   $tags = array();
-  $result = db_query("SELECT * FROM {nodewords} WHERE type = '%s' AND id = '%s'", $type, $id);
+  $language_code = (empty($language_code)) ? _nodewords_language() : $language_code;
+  $result = db_query("SELECT * FROM {nodewords} WHERE type = '%s' AND id = '%s' AND language = '%s'", $type, $id, $language_code);
   while ($row = db_fetch_object($result)) {
     $tags[$row->name] = $row->content;
   }
@@ -428,23 +429,35 @@ function _nodewords_load($type, $id) {
 }
 
 /**
+ * Returns the current language code
+ */
+function _nodewords_language() {
+  if (module_exists('locale')) {
+    global $language;
+    $language_code = $language->language;
+  }
+  // Intentionally returns empty variable if locale is not installed
+  return $language_code;
+}
+
+/**
  * Set one tag
  */
-function _nodewords_update_tag($type, $id, $name, $content) {
-  $result = db_query("SELECT * FROM {nodewords} WHERE type = '%s' AND id = '%s' AND name = '%s'", $type, $id, $name);
+function _nodewords_update_tag($type, $id, $name, $content, $language_code = '') {
+  $result = db_query("SELECT * FROM {nodewords} WHERE type = '%s' AND id = '%s' AND name = '%s' AND language = '%s'", $type, $id, $name, $language_code);
   if (db_result($result) == FALSE) {
-    db_query("INSERT INTO {nodewords} (type, id, name, content) VALUES ('%s', '%s', '%s', '%s')", $type, $id, $name, $content);
+    db_query("INSERT INTO {nodewords} (type, id, name, content, language) VALUES ('%s', '%s', '%s', '%s', '%s')", $type, $id, $name, $content, $language_code);
   }
   else {
-    db_query("UPDATE {nodewords} SET content = '%s' WHERE type = '%s' AND id = '%s' AND name = '%s'", $content, $type, $id, $name);
+    db_query("UPDATE {nodewords} SET content = '%s' WHERE type = '%s' AND id = '%s' AND name = '%s' AND language = '%s'", $content, $type, $id, $name, $language_code);
   }
 }
 
 /**
  * Delete one tag
  */
-function _nodewords_delete_tag($type, $id, $name) {
-  db_query("DELETE FROM {nodewords} WHERE type = '%s' and id = '%s' AND name = '%s'", $type, $id, $name);
+function _nodewords_delete_tag($type, $id, $name, $language = '') {
+  db_query("DELETE FROM {nodewords} WHERE type = '%s' and id = '%s' AND name = '%s' AND language = '%s'", $type, $id, $name, $language);
 }
 
 /**
@@ -595,7 +608,7 @@ function _nodewords_prepare($type, $ids,
 
   // EXCEPTION - QUICK HACK - DANGER AHEAD - BRAIN SWITCH-OFF
   if (isset($tags['geourl'])) {
-    $tags['geourl'] = str_replace(array(' ', '	'), '', $tags['geourl']);
+    $tags['geourl'] = str_replace(array(' ', "\t"), '', $tags['geourl']);
     $tags['geo.position'] = str_replace(',', ';', $tags['geourl']);
     $tags['ICBM'] = str_replace(';', ',', $tags['geourl']);
     // http://drupal.org/node/103399 : we are unable to drupal_get_title(),
