--- locale.inc.orig 2005-03-23 18:03:27.000000000 +0100 +++ locale.inc 2005-03-25 09:58:22.433809358 +0100 @@ -176,11 +176,9 @@ if ($key == 0) { $plid = 0; } - $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english[$key])); + $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND location = '%s'", $english[$key], $comments)); if ($loc->lid) { // a string exists $lid = $loc->lid; - // update location field - db_query("UPDATE {locales_source} SET location = '%s' WHERE id = %d", $comments, $lid); $trans2 = db_fetch_object(db_query("SELECT lid, translation, plid, plural FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $lang)); if (!$trans2->lid) { // no translation in current language db_query("INSERT INTO {locales_target} (lid, locale, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $lang, $trans, $plid, $key); @@ -198,7 +196,7 @@ } else { // no string db_query("INSERT INTO {locales_source} (location, source) VALUES ('%s', '%s')", $comments, $english[$key]); - $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english[$key])); + $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND location = '%s'", $english[$key], $comments)); $lid = $loc->lid; db_query("INSERT INTO {locales_target} (lid, locale, translation, plid, plural) VALUES (%d, '%s', '%s', %d, %d)", $lid, $lang, $trans, $plid, $key); if ($trans != '') { @@ -213,11 +211,10 @@ else { $english = $value['msgid']; $translation = $value['msgstr']; - $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s'", $english)); + $loc = db_fetch_object(db_query("SELECT lid FROM {locales_source} WHERE source = '%s' AND location = '%s'", $english, $comments)); if ($loc->lid) { // a string exists $lid = $loc->lid; // update location field - db_query("UPDATE {locales_source} SET location = '%s' WHERE source = '%s'", $comments, $english); $trans = db_fetch_object(db_query("SELECT lid, translation FROM {locales_target} WHERE lid = %d AND locale = '%s'", $lid, $lang)); if (!$trans->lid) { // no translation in current language db_query("INSERT INTO {locales_target} (lid, locale, translation) VALUES (%d, '%s', '%s')", $lid, $lang, $translation); @@ -662,7 +659,7 @@ while(strlen($comm) < 128 && count($comment)) { $comm .= substr(array_shift($comment), 1) .', '; } - return substr($comm, 0, -2); + return trim(substr($comm, 0, -2)); } /** @@ -689,18 +686,37 @@ } /** + * Get a list of all files with at least one translatable string + */ +function _locale_active_modules() { + $loc = db_query("SELECT location FROM {locales_source}"); + $filenames[''] = t('All files'); + while ($locat = db_fetch_object($loc)) { + $basename = basename(preg_replace('/:.*/', '', $locat->location)); + if ($basename) { + $filenames[$basename] = $basename; + } + } + ksort($filenames); + return $filenames; +} + +/** * User interface for the translation export screen */ function _locale_admin_export_screen() { $languages = locale_supported_languages(FALSE, TRUE); $languages = array_map("t", $languages['name']); unset($languages['en']); + $filenames = _locale_active_modules(); + $output = ''; // Offer language specific export if any language is set up if (count($languages)) { $output .= '