Index: l10n_client.module =================================================================== --- l10n_client.module 2010-01-17 13:36:46.000000000 +0100 +++ l10n_client.module 2010-01-17 13:41:39.000000000 +0100 @@ -163,13 +163,13 @@ function l10n_client_translate_page($dis 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 @@ function l10n_client_footer() { 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. @@ -251,12 +253,14 @@ function l10n_client_footer() { * Source string or NULL if geting the list of strings specified. * @param $translation * Translation string. TRUE if untranslated. + * @param $textgroup + * Text group the string belongs to */ -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; @@ -273,23 +277,22 @@ function l10_client_add_string_to_page($ function _l10n_client_page_strings() { global $language; - // Get the page strins stored by this or other modules. + // Get the page strings stored by this or other modules. $strings = l10_client_add_string_to_page(); // 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 // but will not work reliably in all cases, since strings might have been // found on completely different paths first, or on a slightly different // 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()); + $result = db_query("SELECT s.source, t.translation, s.textgroup 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[$data->textgroup][$data->source] = (empty($data->translation) ? TRUE : $data->translation); } } } @@ -305,7 +308,9 @@ function _l10n_client_dom_strings($strin 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 .= "