diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-21 21:13:29 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2004-08-21 21:13:29 +0000 |
commit | 05714da2ec41bcb389c73d4f95fcbebe78af140c (patch) | |
tree | 3fdd3900434cb2b7456a1ce92b27a1a3adb49dde | |
parent | f52898718b39031f75b2d5fe91b73e18b63c7477 (diff) | |
download | brdo-05714da2ec41bcb389c73d4f95fcbebe78af140c.tar.gz brdo-05714da2ec41bcb389c73d4f95fcbebe78af140c.tar.bz2 |
Locale:
- Fixing broken .po import (due to file.inc changes).
- Do not show error notice on import page when no languages have been added (no longer necessary due to ability to add-and-import in one step).
- Added a notice about importing possibly taking a while.
- Raised the PHP execution time limit for importing (if not in safe mode, similar to cron.php).
-rw-r--r-- | includes/locale.inc | 20 | ||||
-rw-r--r-- | modules/locale.module | 4 | ||||
-rw-r--r-- | modules/locale/locale.module | 4 |
3 files changed, 17 insertions, 11 deletions
diff --git a/includes/locale.inc b/includes/locale.inc index 93c05065f..0bc4ba772 100644 --- a/includes/locale.inc +++ b/includes/locale.inc @@ -94,20 +94,21 @@ function _locale_admin_import_screen() { unset($languages['en']); if (!count($languages)) { - drupal_set_message(t('You need to have at least one language set up to import translations.'), 'error'); + $languages = _locale_prepare_iso_list(); } else { $languages = array( t('Already added languages') => $languages, t('Languages not yet added') => _locale_prepare_iso_list() ); - - $form = form_file(t('Language file'), 'file', 50, t('A gettext Portable Object (.po) file.')); - $form .= form_select(t('Import into'), 'langcode', '', $languages, t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.')); - $form .= form_radios(t('Mode'), 'mode', 'overwrite', array("overwrite" => t('Strings in the uploaded file replace existing ones, new ones are added'), "keep" => t('Existing strings are kept, only new strings are added'))); - $form .= form_submit(t('Import')); - $output = form($form, 'POST', url('admin/locale/language/import'), array('enctype' => 'multipart/form-data')); } + + $form = form_file(t('Language file'), 'file', 50, t('A gettext Portable Object (.po) file.')); + $form .= form_select(t('Import into'), 'langcode', '', $languages, t('Choose the language you want to add strings into. If you choose a language which is not yet set up, then it will be added.')); + $form .= form_radios(t('Mode'), 'mode', 'overwrite', array("overwrite" => t('Strings in the uploaded file replace existing ones, new ones are added'), "keep" => t('Existing strings are kept, only new strings are added'))); + $form .= '<p><strong>Note</strong>: Importing a translation file might take a while.</p>'; + $form .= form_submit(t('Import')); + $output = form($form, 'POST', url('admin/locale/language/import'), array('enctype' => 'multipart/form-data')); return $output; } @@ -119,6 +120,11 @@ function _locale_admin_import_screen() { * @param $mode should existing translations be replaced? */ function _locale_import_po($file, $lang, $mode) { + // If not in 'safe mode', increase the maximum execution time: + if (!ini_get('safe_mode')) { + set_time_limit(240); + } + // Check if we have the language already in the database if (!db_fetch_object(db_query("SELECT locale FROM {locales_meta} WHERE locale = '%s'", $lang))) { drupal_set_message(t('Unsupported language selected for import.'), 'error'); diff --git a/modules/locale.module b/modules/locale.module index 836cb5089..f239bb176 100644 --- a/modules/locale.module +++ b/modules/locale.module @@ -26,7 +26,7 @@ function locale_help($section = "admin/help#locale") { case 'admin/locale/language/add': return t("<p>You need to add all languages you would like to provide the site interface in. If you can't find the desired language in the quick add dropdown, then need to provide the proper language code yourself. The language code might be used to negotiate with browsers and present flags, so it is important to pick one that is standardised for the desired language. You can also add languages by <a href=\"%import\">importing translations</a> directly into a language not yet set up.</p>", array("%import" => url("admin/locale/language/import"))); case 'admin/locale/language/import': - return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization')); + return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal translation page</a>.</p>", array('%url' => 'http://drupal.org/translations')); case 'admin/locale/language/export': return t("<p>This page allows you to export Drupal strings. The first option is to export a translation so it can be shared. The second option is to generate a translation template, which contains all Drupal strings, but without their translations. You can use this template to start a new translation using a specialized desktop application.</p>"); case 'admin/locale/string/search': @@ -385,7 +385,7 @@ function locale_admin_import() { // Now import strings into the language $file = file_check_upload('file'); - if ($ret = _locale_import_po($file->path, $edit['langcode'], $edit['mode']) == FALSE) { + if ($ret = _locale_import_po($file->filepath, $edit['langcode'], $edit['mode']) == FALSE) { watchdog('error', t('Translation import failed.')); watchdog('locale', t('Translation import failed.')); } diff --git a/modules/locale/locale.module b/modules/locale/locale.module index 836cb5089..f239bb176 100644 --- a/modules/locale/locale.module +++ b/modules/locale/locale.module @@ -26,7 +26,7 @@ function locale_help($section = "admin/help#locale") { case 'admin/locale/language/add': return t("<p>You need to add all languages you would like to provide the site interface in. If you can't find the desired language in the quick add dropdown, then need to provide the proper language code yourself. The language code might be used to negotiate with browsers and present flags, so it is important to pick one that is standardised for the desired language. You can also add languages by <a href=\"%import\">importing translations</a> directly into a language not yet set up.</p>", array("%import" => url("admin/locale/language/import"))); case 'admin/locale/language/import': - return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal localization page</a>.</p>", array('%url' => 'http://drupal.org/localization')); + return t("<p>This page allows you to import a translation provided in the gettext Portable Object (.po) format. The easiest way to get your site translated is to grab an existing Drupal translation and to import it. You can obtain translations from the <a href=\"%url\">Drupal translation page</a>.</p>", array('%url' => 'http://drupal.org/translations')); case 'admin/locale/language/export': return t("<p>This page allows you to export Drupal strings. The first option is to export a translation so it can be shared. The second option is to generate a translation template, which contains all Drupal strings, but without their translations. You can use this template to start a new translation using a specialized desktop application.</p>"); case 'admin/locale/string/search': @@ -385,7 +385,7 @@ function locale_admin_import() { // Now import strings into the language $file = file_check_upload('file'); - if ($ret = _locale_import_po($file->path, $edit['langcode'], $edit['mode']) == FALSE) { + if ($ret = _locale_import_po($file->filepath, $edit['langcode'], $edit['mode']) == FALSE) { watchdog('error', t('Translation import failed.')); watchdog('locale', t('Translation import failed.')); } |