Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.2 diff -u -r1.2 install.php --- install.php 31 Jul 2006 19:24:16 -0000 1.2 +++ install.php 1 Aug 2006 12:00:25 -0000 @@ -130,7 +130,7 @@ drupal_maintenance_theme(); drupal_set_message(st('The Drupal installer requires write permissions to %file during the installation process.', array('%file' => $settings_file)), 'error'); - drupal_set_title('Drupal installation'); + drupal_set_title(st('Drupal installation')); print theme('install_page', ''); exit; } @@ -143,7 +143,7 @@ // Database type $form['db_type'] = array( '#type' => 'select', - '#title' => 'Database type', + '#title' => st('Database type'), '#required' => TRUE, '#options' => drupal_detect_database_types(), '#default_value' => $db_type, @@ -152,7 +152,7 @@ // Database username $form['db_user'] = array( '#type' => 'textfield', - '#title' => 'Database username', + '#title' => st('Database username'), '#default_value' => $db_user, '#size' => 45, '#maxlength' => 45, @@ -163,7 +163,7 @@ // Database username $form['db_pass'] = array( '#type' => 'password', - '#title' => 'Database password', + '#title' => st('Database password'), '#default_value' => $db_pass, '#size' => 45, '#maxlength' => 45, @@ -174,7 +174,7 @@ // Database name $form['db_path'] = array( '#type' => 'textfield', - '#title' => 'Database name', + '#title' => st('Database name'), '#default_value' => $db_path, '#size' => 45, '#maxlength' => 45, @@ -185,7 +185,7 @@ // Database host $form['db_host'] = array( '#type' => 'textfield', - '#title' => 'Database host', + '#title' => st('Database host'), '#default_value' => $db_host, '#size' => 45, '#maxlength' => 45, @@ -196,17 +196,17 @@ // Database prefix $form['db_prefix'] = array( '#type' => 'textfield', - '#title' => 'Database prefix', + '#title' => st('Database prefix'), '#default_value' => $db_prefix, '#size' => 45, '#maxlength' => 45, '#required' => FALSE, - '#description' => 'Optionally set a prefix for all database table names. If a prefix is specified, all table names will be prepended with this value. Only alphanumeric characters and the underscore are allowed. If you do not wish to use a prefix, leave this field empty. If you wish to only prefix specific tables, you will need to manually edit your settings.php configuration file.', + '#description' => st('Optionally set a prefix for all database table names. If a prefix is specified, all table names will be prepended with this value. Only alphanumeric characters and the underscore are allowed. If you do not wish to use a prefix, leave this field empty. If you wish to only prefix specific tables, you will need to manually edit your settings.php configuration file.'), ); $form['save'] = array( '#type' => 'submit', - '#value' => 'Save configuration', + '#value' => st('Save configuration'), ); $form['errors'] = array(); $form['settings_file'] = array('#type' => 'value', '#value' => $settings_file); @@ -215,7 +215,7 @@ $form['#redirect'] = NULL; drupal_maintenance_theme(); $output = drupal_get_form('install_settings', $form); - drupal_set_title('Database configuration'); + drupal_set_title(st('Database configuration')); print theme('install_page', st('
Please fill out the following information to configure your %drupal site.
', array('%drupal' => drupal_install_profile_name())). $output); exit; } @@ -338,10 +338,10 @@ } $form['submit'] = array( '#type' => 'submit', - '#value' => 'Save configuration', + '#value' => st('Save configuration'), ); - drupal_set_title('Select an installation profile'); + drupal_set_title(st('Select an installation profile')); print theme('install_page', drupal_get_form('install_select_profile', $form)); exit; } @@ -352,8 +352,8 @@ */ function install_no_profile_error() { drupal_maintenance_theme(); - drupal_set_title('No profiles available'); - print theme('install_page', 'We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.
'); + drupal_set_title(st('No profiles available')); + print theme('install_page', st('We were unable to find any installer profiles. Installer profiles tell us what modules to enable and what schema to install in the database. A profile is necessary to continue with the installation process.
')); exit; } @@ -363,8 +363,8 @@ */ function install_already_done_error() { drupal_maintenance_theme(); - drupal_set_title('Drupal already installed'); - print theme('install_page', 'Drupal has already been installed on this site. To start over, you must empty your existing database. To install to a different database, edit the appropriate settings.php file in the sites folder.
'); + drupal_set_title(st('Drupal already installed')); + print theme('install_page', st('Drupal has already been installed on this site. To start over, you must empty your existing database. To install to a different database, edit the appropriate settings.php file in the sites folder.
')); exit; } @@ -392,7 +392,7 @@ } else { // No more steps - $msg = drupal_set_message() ? 'Please review the messages above before continuing on to your new site.' : 'You may now visit your new site.'; + $msg = drupal_set_message() ? st('Please review the messages above before continuing on to your new site.') : st('You may now visit your new site.'); $output .= strtr(''. $msg .'
', array('%url' => url(''))); } Index: includes/install.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/install.inc,v retrieving revision 1.10 diff -u -r1.10 install.inc --- includes/install.inc 31 Jul 2006 19:24:16 -0000 1.10 +++ includes/install.inc 1 Aug 2006 12:00:25 -0000 @@ -546,6 +546,18 @@ * when the theme system is not available. */ function st($string, $args = array()) { + static $locale_strings = NULL; + + if (!isset($locale_strings)) { + $locale_strings = array(); + if (file_exists('./locale/installer.po')) { + require_once './includes/locale.inc'; + $file = (object) array('filepath' => './locale/installer.po'); + _locale_import_read_po($file, 'installer', 'dummy'); + $locale_strings = _locale_import_one_string('report-installer', 'installer'); + } + } + require_once './includes/theme.inc'; - return strtr($string, array_map('theme_placeholder', $args)); -} \ No newline at end of file + return strtr((!empty($locale_strings[$string]) ? $locale_strings[$string] : $string), array_map('theme_placeholder', $args)); +} Index: includes/locale.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/locale.inc,v retrieving revision 1.83 diff -u -r1.83 locale.inc --- includes/locale.inc 31 Jul 2006 11:25:52 -0000 1.83 +++ includes/locale.inc 1 Aug 2006 12:00:26 -0000 @@ -491,10 +491,9 @@ */ function _locale_import_read_po($file, $mode, $lang) { - $message = theme('placeholder', $file->filename); $fd = fopen($file->filepath, "rb"); // File will get closed by PHP on return if (!$fd) { - drupal_set_message(t('The translation import failed, because the file %filename could not be read.', array('%filename' => $message)), 'error'); + _locale_import_message('The translation import failed, because the file %filename could not be read.', $file); return FALSE; } @@ -519,19 +518,19 @@ $context = "COMMENT"; } else { // Parse error - drupal_set_message(t('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: "msgstr" was expected but not found on line %line.', $file, $lineno); return FALSE; } } elseif (!strncmp("msgid_plural", $line, 12)) { if ($context != "MSGID") { // Must be plural form for current entry - drupal_set_message(t('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: "msgid_plural" was expected but not found on line %line.', $file, $lineno); return FALSE; } $line = trim(substr($line, 12)); $quoted = _locale_import_parse_quoted($line); if ($quoted === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } $current["msgid"] = $current["msgid"] ."\0". $quoted; @@ -543,13 +542,13 @@ $current = array(); } elseif ($context == "MSGID") { // Already in this context? Parse error - drupal_set_message(t('The translation file %filename contains an error: "msgid" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: "msgid" is unexpected on line %line.', $file, $lineno); return FALSE; } $line = trim(substr($line, 5)); $quoted = _locale_import_parse_quoted($line); if ($quoted === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } $current["msgid"] = $quoted; @@ -557,11 +556,11 @@ } elseif (!strncmp("msgstr[", $line, 7)) { if (($context != "MSGID") && ($context != "MSGID_PLURAL") && ($context != "MSGSTR_ARR")) { // Must come after msgid, msgid_plural, or msgstr[] - drupal_set_message(t('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: "msgstr[]" is unexpected on line %line.', $file, $lineno); return FALSE; } if (strpos($line, "]") === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } $frombracket = strstr($line, "["); @@ -569,7 +568,7 @@ $line = trim(strstr($line, " ")); $quoted = _locale_import_parse_quoted($line); if ($quoted === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } $current["msgstr"][$plural] = $quoted; @@ -577,13 +576,13 @@ } elseif (!strncmp("msgstr", $line, 6)) { if ($context != "MSGID") { // Should come just after a msgid block - drupal_set_message(t('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: "msgstr" is unexpected on line %line.', $file, $lineno); return FALSE; } $line = trim(substr($line, 6)); $quoted = _locale_import_parse_quoted($line); if ($quoted === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } $current["msgstr"] = $quoted; @@ -592,7 +591,7 @@ elseif ($line != "") { $quoted = _locale_import_parse_quoted($line); if ($quoted === FALSE) { - drupal_set_message(t('The translation file %filename contains a syntax error on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains a syntax error on line %line.', $file, $lineno); return FALSE; } if (($context == "MSGID") || ($context == "MSGID_PLURAL")) { @@ -605,7 +604,7 @@ $current["msgstr"][$plural] .= $quoted; } else { - drupal_set_message(t('The translation file %filename contains an error: there is an unexpected string on line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename contains an error: there is an unexpected string on line %line.', $file, $lineno); return FALSE; } } @@ -616,13 +615,38 @@ _locale_import_one_string($current, $mode, $lang); } elseif ($context != "COMMENT") { - drupal_set_message(t('The translation file %filename ended unexpectedly at line %line.', array('%filename' => $message, '%line' => $lineno)), 'error'); + _locale_import_message('The translation file %filename ended unexpectedly at line %line.', $file, $lineno); return FALSE; } } /** + * Sets an error message occured during locale file parsing. + * + * @param $message + * The message to be translated + * @param $file + * A drupal file object of the PO file + * @param $lineno + * An optional line number argument + */ +function _locale_import_message($message, $file, $lineno = NULL) { + $vars = (isset($lineno) ? array('%line' => $lineno) : array()); + + // Normal import functonality + if (function_exists('theme') && function_exists('t')) { + $vars['%filename'] = theme('placeholder', $file->filename); + drupal_set_message(t($message, $vars), 'error'); + } + // Installer + else { + $vars['%filename'] = $file->filename; + drupal_set_message(st($message, $vars), 'error'); + } +} + +/** * Imports a string into the database * * @param $value Information about the string @@ -632,11 +656,22 @@ static $additions = 0; static $updates = 0; static $headerdone = FALSE; + static $installer_strings = array(); // Report the changes made (called at end of import) if ($value == 'report') { return array($headerdone, $additions, $updates); } + + // Special cases for the installer + elseif ($value == 'report-installer') { + return $installer_strings; + } + elseif ($mode == 'installer') { + $installer_strings[$value['msgid']] = $value['msgstr']; + return; + } + // Current string is the header information elseif ($value['msgid'] == '') { $hdr = _locale_import_parse_header($value['msgstr']);