direction. */ define('LANGUAGE_LTR', 0); /** * Language written right to left. Possible value of $language->direction. */ define('LANGUAGE_RTL', 1); // --------------------------------------------------------------------------------- // Hook implementations /** * Implementation of hook_help(). */ function locale_help($path, $arg) { switch ($path) { case 'admin/help#locale': $output = '
'. t('The locale module allows your Drupal site to be presented in languages other than the default English, a defining feature of multi-lingual websites. The locale module works by examining text as it is about to be displayed: when a translation of the text is available in the language to be displayed, the translation is displayed rather than the original text. When a translation is unavailable, the original text is displayed, and then stored for later review by a translator.') .'
'; $output .= ''. t('Beyond translation of the Drupal interface, the locale module provides a feature set tailored to the needs of a multi-lingual site. Language negotiation allows your site to automatically change language based on the domain or path used for each request. Users may (optionally) select their preferred language on their My account page, and your site can be configured to honor a web browser\'s preferred language settings. Your site content can be created in (and translated to) any enabled language, and each post may have a language-appropriate alias for each of its translations. The locale module works in concert with the content translation module to manage translated content.', array('@content-help' => url('admin/help/translation'))) .'
'; $output .= ''. t('Translations may be provided by:') .'
'; $output .= ''. t('If an existing translation package does not meet your needs, the Gettext Portable Object (.po) files within a package may be modified, or new .po files may be created, using a desktop Gettext editor. The locale module\'s import feature allows the translated strings from a new or modified .po file to be added to your site. The locale module\'s export feature generates files from your site\'s translated strings, that can either be shared with others or edited offline by a Gettext translation editor.', array('@import' => url('admin/build/translate/import'), '@export' => url('admin/build/translate/export'))) .'
'; $output .= ''. t('For more information, see the online handbook entry for Locale module.', array('@locale' => 'http://drupal.org/handbook/modules/locale/')) .'
'; return $output; case 'admin/settings/language': $output = ''. t("This page provides an overview of your site's enabled languages. If multiple languages are available and enabled, the text on your site interface may be translated, registered users may select their preferred language on the My account page, and site authors may indicate a specific language when creating posts. The site's default language is used for anonymous visitors and for users who have not selected a preferred language.") .'
'; $output .= ''. t('For each language available on the site, use the edit link to configure language details, including name, an optional language-specific path or domain, and whether the language is natively presented either left-to-right or right-to-left. These languages also appear in the Language selection when creating a post of a content type with multilingual support.') .'
'; $output .= ''. t('Use the add language page to enable additional languages (and automatically import files from a translation package, if available), the translate interface page to locate strings for manual translation, or the import page to add translations from individual .po files. A number of contributed translation packages containing .po files are available on the Drupal.org translations page.', array('@add-language' => url('admin/settings/language/add'), '@search' => url('admin/build/translate/search'), '@import' => url('admin/build/translate/import'), '@translations' => 'http://drupal.org/project/translations')) .'
'; return $output; case 'admin/settings/language/add': return ''. t('Add all languages to be supported by your site. If your desired language is not available in the Language name drop-down, click Custom language and provide a language code and other details manually. When providing a language code manually, be sure to enter a standardized language code, since this code may be used by browsers to determine an appropriate display language.') .'
'; case 'admin/settings/language/configure': $output = ''. t("Language negotiation settings determine the site's presentation language. Available options include:") .'
'; $output .= ''. t('The path prefix or domain name for a language may be set by editing the available languages. In the absence of an appropriate match, the site is displayed in the default language.', array('@languages' => url('admin/settings/language'))) .'
'; return $output; case 'admin/build/translate': $output = ''. t('This page provides an overview of available translatable strings. Drupal displays translatable strings in text groups; modules may define additional text groups containing other translatable strings. Because text groups provide a method of grouping related strings, they are often used to focus translation efforts on specific areas of the Drupal interface.') .'
'; $output .= ''. t('Review the languages page for more information on adding support for additional languages.', array('@languages' => url('admin/settings/language'))) .'
'; return $output; case 'admin/build/translate/import': $output = ''. t('This page imports the translated strings contained in an individual Gettext Portable Object (.po) file. Normally distributed as part of a translation package (each translation package may contain several .po files), a .po file may need to be imported after off-line editing in a Gettext translation editor. Importing an individual .po file may be a lengthy process.') .'
'; $output .= ''. t('Note that the .po files within a translation package are imported automatically (if available) when new modules or themes are enabled, or as new languages are added. Since this page only allows the import of one .po file at a time, it may be simpler to download and extract a translation package into your Drupal installation directory and add the language (which automatically imports all .po files within the package). Translation packages are available for download on the Drupal translation page.', array('@language-add' => url('admin/settings/language/add'), '@translations' => 'http://drupal.org/project/translations')) .'
'; return $output; case 'admin/build/translate/export': return ''. t('This page exports the translated strings used by your site. An export file may be in Gettext Portable Object (.po) form, which includes both the original string and the translation (used to share translations with others), or in Gettext Portable Object Template (.pot) form, which includes the original strings only (used to create new translations with a Gettext translation editor).') .'
'; case 'admin/build/translate/search': return ''. t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: For translation tasks involving many strings, it may be more convenient to export strings for off-line editing in a desktop Gettext translation editor.) Searches may be limited to strings found within a specific text group or in a specific language.', array('@export' => url('admin/build/translate/export'))) .'
'; case 'admin/build/block/configure': if ($arg[4] == 'locale' && $arg[5] == 0) { return ''. t('This block is only shown if at least two languages are enabled and language negotiation is set to something other than None.', array('@languages' => url('admin/settings/language'), '@configuration' => url('admin/settings/language/configure'))) .'
'; } break; } } /** * Implementation of hook_menu(). * * Locale module only provides administrative menu items, so all * menu items are invoked through locale_inc_callback(). */ function locale_menu() { // Manage languages $items['admin/settings/language'] = array( 'title' => 'Languages', 'description' => 'Configure languages for content and the user interface.', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_languages_overview_form'), 'access arguments' => array('administer languages'), ); $items['admin/settings/language/overview'] = array( 'title' => 'List', 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/settings/language/add'] = array( 'title' => 'Add language', 'page callback' => 'locale_inc_callback', 'page arguments' => array('locale_languages_add_screen'), // two forms concatenated 'weight' => 5, 'type' => MENU_LOCAL_TASK, ); $items['admin/settings/language/configure'] = array( 'title' => 'Configure', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_languages_configure_form'), 'weight' => 10, 'type' => MENU_LOCAL_TASK, ); $items['admin/settings/language/edit/%'] = array( 'title' => 'Edit language', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_languages_edit_form', 4), 'type' => MENU_CALLBACK, ); $items['admin/settings/language/delete/%'] = array( 'title' => 'Confirm', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_languages_delete_form', 4), 'type' => MENU_CALLBACK, ); // Translation functionality $items['admin/build/translate'] = array( 'title' => 'Translate interface', 'description' => 'Translate the built in interface as well as menu items and taxonomies.', 'page callback' => 'locale_inc_callback', 'page arguments' => array('locale_translate_overview_screen'), // not a form, just a table 'access arguments' => array('translate interface'), ); $items['admin/build/translate/overview'] = array( 'title' => 'Overview', 'weight' => 0, 'type' => MENU_DEFAULT_LOCAL_TASK, ); $items['admin/build/translate/search'] = array( 'title' => 'Search', 'weight' => 10, 'type' => MENU_LOCAL_TASK, 'page callback' => 'locale_inc_callback', 'page arguments' => array('locale_translate_seek_screen'), // search results and form concatenated ); $items['admin/build/translate/import'] = array( 'title' => 'Import', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_translate_import_form'), 'weight' => 20, 'type' => MENU_LOCAL_TASK, ); $items['admin/build/translate/export'] = array( 'title' => 'Export', 'page callback' => 'locale_inc_callback', 'page arguments' => array('locale_translate_export_screen'), // possibly multiple forms concatenated 'weight' => 30, 'type' => MENU_LOCAL_TASK, ); $items['admin/build/translate/edit/%'] = array( 'title' => 'Edit string', 'page callback' => 'locale_inc_callback', 'page arguments' => array('drupal_get_form', 'locale_translate_edit_form', 4), 'type' => MENU_CALLBACK, ); $items['admin/build/translate/delete/%'] = array( 'title' => 'Delete string', 'page callback' => 'locale_inc_callback', 'page arguments' => array('locale_translate_delete', 4), // directly deletes, no confirmation 'type' => MENU_CALLBACK, ); return $items; } /** * Wrapper function to be able to set callbacks in locale.inc */ function locale_inc_callback() { $args = func_get_args(); $function = array_shift($args); include_once './includes/locale.inc'; return call_user_func_array($function, $args); } /** * Implementation of hook_perm(). */ function locale_perm() { return array('administer languages', 'translate interface'); } /** * Implementation of hook_locale(). */ function locale_locale($op = 'groups') { switch ($op) { case 'groups': return array('default' => t('Built-in interface')); } } /** * Implementation of hook_user(). */ function locale_user($type, $edit, &$user, $category = NULL) { global $language; // If we have more then one language and either creating a user on the // admin interface or edit the user, show the language selector. if (variable_get('language_count', 1) > 1 && ($type == 'register' && user_access('administer users') || $type == 'form' && $category == 'account' )) { $languages = language_list('enabled'); $languages = $languages['1']; // If the user is being created, we set the user language to the page language. $user_preferred_language = $user ? user_preferred_language($user) : $language; $names = array(); foreach ($languages as $langcode => $item) { $name = t($item->name); $names[$langcode] = $name . ($item->native != $name ? ' ('. $item->native .')' : ''); } $form['locale'] = array( '#type' => 'fieldset', '#title' => t('Language settings'), '#weight' => 1, ); $form['locale']['language'] = array( '#type' => (count($names) <= 5 ? 'radios' : 'select'), '#title' => t('Language'), '#default_value' => $user_preferred_language->language, '#options' => $names, '#description' => t('Sets the default site interface and e-mail language for this account.'), ); return $form; } } /** * Implementation of hook_form_alter(). Adds language fields to forms. */ function locale_form_alter(&$form, $form_state, $form_id) { switch ($form_id) { // Language field for paths case 'path_admin_form': $form['language'] = array( '#type' => 'select', '#title' => t('Language'), '#options' => array('' => t('All languages')) + locale_language_list('name'), '#default_value' => $form['language']['#value'], '#weight' => -10, '#description' => t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set for