--- C:/Documents and Settings/John/Bureau/l10n_client-6.x-1.7/l10n_client/l10n_client.module	Wed Apr 15 21:10:12 2009
+++ C:/Documents and Settings/John/Bureau/l10n_client.module	Sun Aug 16 12:59:20 2009
@@ -163,13 +163,13 @@
     if ($display_translated) {
       $table[] = array(check_plain($data->source), check_plain($data->translation));
       if ($allow_translation) {
-        l10_client_add_string_to_page($data->source, $data->translation);
+        l10_client_add_string_to_page($data->source, $data->translation, $textgroup);
       }
     }
     else {
       $table[] = array(check_plain($data->source));
       if ($allow_translation) {
-        l10_client_add_string_to_page($data->source, TRUE);
+        l10_client_add_string_to_page($data->source, TRUE, $textgroup);
       }
     }
   }
@@ -196,8 +196,10 @@
   if (user_access('use on-page translation') && ($page_strings = _l10n_client_page_strings())) {
     // If we have strings for the page language, restructure the data.
     $l10n_strings = array();
-    foreach ($page_strings as $string => $translation) {
-      $l10n_strings[] = array($string, $translation);
+    foreach ($page_strings as $textgroup => $group_strings) {
+      foreach ($group_strings as $string => $translation) {
+        $l10n_strings[] = array($string, $translation, $textgroup);
+      }
     }
     array_multisort($l10n_strings);
     // Include string selector on page.
@@ -252,11 +254,11 @@
  * @param $translation
  *   Translation string. TRUE if untranslated.
  */
-function l10_client_add_string_to_page($source = NULL, $translation = NULL) {
+function l10_client_add_string_to_page($source = NULL, $translation = NULL, $textgroup = 'default') {
   static $strings = array();
   
   if (isset($source)) {
-    $strings[$source] = $translation;
+    $strings[$textgroup][$source] = $translation;
   }
   else {
     return $strings;
@@ -279,7 +281,8 @@
   // If this is not the module's translation page, merge all strings used on the page.
   if (arg(0) != 'locale' && is_array($locale = locale()) && isset($locale[$language->language])) {
     
-    $strings = array_merge($strings, $locale[$language->language]);
+    $strings += array('default' => array());
+    $strings['default'] = array_merge($strings['default'], $locale[$language->language]);
     
     // Also select and add other strings for this path. Other users may have run
     // into these strings for the same page. This might be useful in some cases
@@ -288,8 +291,8 @@
     // path.
     $result = db_query("SELECT s.source, t.translation FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE s.location = '%s'", $language->language, request_uri());
     while ($data = db_fetch_object($result)) {
-      if (!array_key_exists($data->source, $strings)) {
-        $strings[$data->source] = (empty($data->translation) ? TRUE : $data->translation);
+      if (!array_key_exists($data->source, $strings['default'])) {
+        $strings['default'][$data->source] = (empty($data->translation) ? TRUE : $data->translation);
       }
     }
   }
@@ -305,7 +308,8 @@
   foreach ($strings as $values) {
     $source = $values[0] === TRUE ? '' : htmlspecialchars($values[0], ENT_NOQUOTES, 'UTF-8');
     $target = $values[1] === TRUE ? '' : htmlspecialchars($values[1], ENT_NOQUOTES, 'UTF-8');
-    $output .= "<div><span class='source'>$source</span><span class='target'>$target</span></div>";
+    $textgroup = $values[2];
+    $output .= "<div><span class='source'>$source</span><span class='target'>$target</span><span class='textgroup'>$textgroup</span></div>";
   }
   return "<div id='l10n-client-data'>$output</div>";
 }
@@ -368,16 +372,20 @@
     '#type' => 'textarea',
     '#resizable' => false,
     '#rows' => 6,
+	'#id' => 'l10n-edit-target',
   );
   $form['save'] = array(
     '#value' => t('Save translation'),
     '#type' => 'submit',
+	'#id' => 'l10n-edit-save',
   );
+  // Hidden field for textgroup
+  $form['textgroup'] = array('#type' => 'hidden', '#value' => 'default', '#id' => 'l10n-edit-textgroup');
   $form['copy'] = array(
-    '#value' => "<input id='edit-copy' class='form-submit' type='button' value='". t('Copy Source') ."'/>",
+    '#value' => "<input id='l10n-edit-copy' class='form-submit' type='button' value='". t('Copy Source') ."'/>",
   );
   $form['clear'] = array(
-    '#value' => "<input id='edit-clear' class='form-submit' type='button' value='". t('Clear') ."'/>",
+    '#value' => "<input id='l10n-edit-clear' class='form-submit' type='button' value='". t('Clear') ."'/>",
   );
   
   return $form;
@@ -392,6 +400,7 @@
   $form = array();
   $form['search'] = array(
     '#type' => 'textfield',
+	'#id' => 'l10n-edit-search',
   );
   $form['clear-button'] = array(
     '#value' => "<input id='search-filter-clear' class='form-submit' type='button' value='". t('X') ."'/>",
@@ -406,10 +415,10 @@
   global $user, $language;
   
   if (user_access('use on-page translation')) {
-    if (isset($_POST['source']) && isset($_POST['target']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
+    if (isset($_POST['source']) && isset($_POST['target']) && isset($_POST['textgroup']) && !empty($_POST['form_token']) && drupal_valid_token($_POST['form_token'], 'l10n_client_form')) {
       include_once 'includes/locale.inc';
       $report = array(0, 0, 0);
-      _locale_import_one_string_db($report, $language->language, $_POST['source'], $_POST['target'], 'default', NULL, LOCALE_IMPORT_OVERWRITE);
+      _locale_import_one_string_db($report, $language->language, $_POST['source'], $_POST['target'], $_POST['textgroup'], NULL, LOCALE_IMPORT_OVERWRITE);
       cache_clear_all('locale:', 'cache', TRUE);
       _locale_invalidate_js($language->language);
       
