Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.175 diff -u -p -r1.175 locale.module --- modules/locale/locale.module 28 May 2007 06:08:42 -0000 1.175 +++ modules/locale/locale.module 28 May 2007 12:58:38 -0000 @@ -55,6 +55,9 @@ function locale_help($section) { return '

'. t("This page allows you to export Drupal strings. The first option is to export a translation so it can be shared. The second option generates a translation template, which contains all Drupal strings, but without their translations. You can use this template to start a new translation using various software packages designed for this task.") .'

'; case 'admin/build/translate/search': return '

'. t("It is often convenient to get the strings from your setup on the export page, and use a desktop Gettext translation editor to edit the translations. On this page you can search in the translated and untranslated strings, and the default English texts provided by Drupal.", array("@export" => url("admin/build/translate/export"))) .'

'; + + case 'admin/build/block/configure/locale/0': + return '

'. t("This block is only shown if you have at least two languages enabled and you have a language negotiation setting different from 'none', so you have different web addresses for different language versions.", array('@languages' => 'admin/settings/language', '@configuration' => url('admin/settings/language/configure'))) .'

'; } } @@ -480,3 +483,42 @@ function _locale_batch_import($filepath, $context['results'][] = $filepath; } } + +// --------------------------------------------------------------------------------- +// Language switcher block + +/** + * Implementation of hook_block(). + * Displays a language switcher. Translation links may be provided by other modules. + */ +function locale_block($op = 'list', $delta = 0) { + if ($op == 'list') { + $block[0]['info'] = t('Language switcher'); + return $block; + } + + // Only show if we have at least two languages and language dependent + // web addresses, so we can actually link to other language versions. + elseif ($op == 'view' && variable_get('language_count', 1) > 1 && variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE) != LANGUAGE_NEGOTIATION_NONE) { + $languages = language_list('enabled'); + $links = array(); + foreach ($languages[1] as $language) { + $links[$language->language] = array( + 'href' => $_GET['q'], + 'title' => $language->native, + 'language' => $language, + 'attributes' => array('class' => 'language-link'), + ); + } + + // Allow modules to provide translations for specific links. + // A translation link may need to point to a different path or use + // a translated link text before going through l(), which will just + // handle the path aliases. + drupal_alter('translation_link', $links, $_GET['q']); + + $block['subject'] = t('Languages'); + $block['content'] = theme('links', $links, array()); + return $block; + } +}