diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCompareTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCompareTest.php index 1f176bf..d4c448f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleCompareTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleCompareTest.php @@ -36,6 +36,12 @@ public static function getInfo() { ); } + /** + * Setup the test environment. + * + * We use German as default test language. Due to hardcoded configurations in + * the locale_test module, the language can not be chosen randomly. + */ function setUp() { parent::setUp(); module_load_include('compare.inc', 'locale'); @@ -75,7 +81,7 @@ private function makePoFile($path, $filename, $timestamp = NULL, $data = '') { $po_header = <<set('locale_translation_test_projects', TRUE); // Setup timestamps to identify old and new translation sources. - $timestamp_old = REQUEST_TIME - 100; - $timestamp_new = REQUEST_TIME; + $timestamp_old = REQUEST_TIME - 100; + $timestamp_new = REQUEST_TIME; // Setup the environment. $public_path = variable_get('file_public_path', conf_path() . '/files'); @@ -192,15 +198,12 @@ function testCompareCheckLocal() { $this->makePoFile('remote/8.x/contrib_module_three', 'contrib_module_three-8.x-1.0.de.txt', $timestamp_old); // Add a number of files to the local file system to serve as local - // translation files and match the projct definitions set in + // translation files and match the project definitions set in // locale_test_locale_translation_projects_alter(). $this->makePoFile('local', 'contrib_module_one-8.x-1.1.de.txt', $timestamp_old); $this->makePoFile('local', 'contrib_module_two-8.x-2.0-beta4.de.txt', $timestamp_new); $this->makePoFile('local', 'custom_module_one.de.po', $timestamp_new); - //debug(file_scan_directory(variable_get('file_public_path', conf_path() . '/files') . '/local', '/.*\.*/', array('recurse' => TRUE))); - //debug(file_scan_directory(variable_get('file_public_path', conf_path() . '/files') . '/remote', '/.*\.*/', array('recurse' => TRUE))); - // Get status of translation sources at local file system. $config->set('translation.check_mode', LOCALE_TRANSLATION_CHECK_LOCAL)->save(); $this->drupalGet('admin/reports/translations/check'); @@ -223,6 +226,6 @@ function testCompareCheckLocal() { $this->assertEqual($result['contrib_module_three']['de']->type, 'remote', 'Translation of contrib_module_three found'); $this->assertEqual($result['contrib_module_three']['de']->timestamp, $timestamp_old, 'Translation timestamp found'); $this->assertEqual($result['locale_test']['de']->type, 'local', 'Translation of locale_test found'); - $this->assertEqual($result['custom_module_one']['de']->type, 'local', 'Translation of custom_module_one. found'); + $this->assertEqual($result['custom_module_one']['de']->type, 'local', 'Translation of custom_module_one found'); } } diff --git a/core/modules/locale/locale.api.php b/core/modules/locale/locale.api.php index ea1085f..5005018 100644 --- a/core/modules/locale/locale.api.php +++ b/core/modules/locale/locale.api.php @@ -28,7 +28,7 @@ * the module's folder. * @code * interface translation project = example_module - * interface translation server pattern = sites/all/modules/custom/example_module/%project-%version.%language.po + * interface translation server pattern = modules/custom/example_module/%project-%version.%language.po * @endcode * * Streamwrappers can be used in the server pattern definition. The interface diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index 1e659fc..92c998d 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -2,7 +2,7 @@ /** * @file - * Batch proces to check the availability of remote Gettext .po files. + * Batch process to check the availability of remote or local po files. */ /** @@ -10,7 +10,7 @@ * * The batch process fetches the state of both remote and (if configured) local * translation files. The data of the most recent translation is stored per - * per project and per language. This data is stored a state variable + * per project and per language. This data is stored in a state variable * 'locale_translation_status'. The timestamp it was last updated is stored * in the state variable 'locale_translation_status_last_update'. * @@ -53,6 +53,9 @@ function locale_translation_batch_status_build($sources) { * @param array $context * The batch context array. The collected state is stored in the 'results' * parameter of the context. + * + * @see locale_translation_batch_status_fetch_local() + * @see locale_translation_batch_status_compare() */ function locale_translation_batch_status_fetch_remote($source, &$context) { // Check the translation file at the remote server and update the source @@ -62,7 +65,7 @@ function locale_translation_batch_status_fetch_remote($source, &$context) { $result = locale_translation_http_check($remote_file->url); // Update the file object with the result data. In case of a redirect we - // we store the resulting url. + // store the resulting url. if ($result && !empty($result->updated)) { $remote_file->url = isset($result->redirect_url) ? $result->redirect_url : $remote_file->url; $remote_file->timestamp = $result->updated; @@ -84,6 +87,9 @@ function locale_translation_batch_status_fetch_remote($source, &$context) { * @param array $context * The batch context array. The collected state is stored in the 'results' * parameter of the context. + * + * @see locale_translation_batch_status_fetch_remote() + * @see locale_translation_batch_status_compare() */ function locale_translation_batch_status_fetch_local($sources, &$context) { module_load_include('compare.inc', 'locale'); @@ -116,6 +122,9 @@ function locale_translation_batch_status_fetch_local($sources, &$context) { * @param array $context * The batch context array. The 'results' element contains a structured array * of project data with languages, local and remote source data. + * + * @see locale_translation_batch_status_fetch_remote() + * @see locale_translation_batch_status_fetch_local() */ function locale_translation_batch_status_compare(&$context) { module_load_include('compare.inc', 'locale'); diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index 8df171b..99506d2 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -313,8 +313,7 @@ function locale_translation_check_projects_batch($projects, $langcodes = NULL) { $sources = array(); foreach ($projects as $name => $project) { foreach ($langcodes as $langcode) { - $project_clone = clone $project; - $source = locale_translation_source_build($project_clone, $langcode); + $source = locale_translation_source_build($project, $langcode); $sources[] = $source; } } @@ -328,7 +327,7 @@ function locale_translation_check_projects_batch($projects, $langcodes = NULL) { /** * Check and store the status and timestamp of local po files. * - * Only po files in the local file system and checked. Any remote translation + * Only po files in the local file system are checked. Any remote translation * sources will be ignored. Results are stored in the state variable * 'locale_translation_status'. * @@ -395,8 +394,9 @@ function locale_translation_source_check_file(&$source) { $directory = $source->files['local']->directory; $filename = '/' . preg_quote($source->files['local']->filename) . '$/'; - // If the directory contains a streamwrapper, it is converted to a real - // path. + // If the directory contains a stream wrapper, it is converted to a real + // path. This is required for file_scan_directory() which can not handle + // stream wrappers. if ($scheme = file_uri_scheme($directory)) { $directory = str_replace($scheme . '://', drupal_realpath($scheme . '://'), $directory); } @@ -445,6 +445,7 @@ function locale_translation_source_check_file(&$source) { */ // @todo Move this file? function locale_translation_source_build($project, $langcode, $filename = NULL) { + // Create a source object with data of the project object. $source = clone $project; $source->project = $project->name; $source->language = $langcode; @@ -483,13 +484,13 @@ function locale_translation_source_build($project, $langcode, $filename = NULL) } /** - * Determine if the source file is a remote or a local file. + * Determine if a file is a remote file. * * @param string $url * The URL or URL pattern of the file. * * @return boolean - * TRUE if the $url is a remote file location. + * TRUE if the $url is a remote file. */ function _locale_translation_file_is_remote($url) { $scheme = file_uri_scheme($url); @@ -515,7 +516,6 @@ function _locale_translation_file_is_remote($url) { * - "0": $source1 == $source2 OR both $source1 and $source2 are missing. * - "1": $source1 > $source2 OR $source2 is missing. */ -// @todo Move to locale.inc? function _locale_translation_source_compare($source1, $source2) { if (isset($source1->timestamp) && isset($source2->timestamp)) { if (abs($source1->timestamp - $source2->timestamp) < LOCALE_TRANSLATION_TIMESTAMP_THRESHOLD) { diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 3fe1968..37495cf 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -463,22 +463,22 @@ function locale_translation_manual_status() { /** * Page callback: Display the current translation status. + * + * @see locale_menu() */ function locale_translation_status() { $languages = locale_translatable_language_list(); if (!$languages) { - drupal_set_message(t('No translatable languages available. Add a language first.', array('@add_lanuage' => url('admin/config/regional/language'))), 'warning'); + drupal_set_message(t('No translatable languages available.') . ' ' . l(t('Add language'), 'admin/config/regional/language'), 'warning'); } -//debug(state()->get('locale_translation_status')); -//debug(format_date(state()->get('locale_translation_status_last_update'), 'long')); - - // @todo Calculate and display the translation status here. - return 'TODO: Show the transaltion status here'; + // @todo Calculate and display the translation status here. See the follow-up + // issue for translation interface: http://drupal.org/node/1804702 + return 'TODO: Show the translation status here'; } /** - * Default theme function for translatione edit form. + * Default theme function for translation edit form. */ function theme_locale_translate_edit_form_strings($variables) { $output = ''; diff --git a/core/modules/locale/tests/modules/locale_test/locale_test.module b/core/modules/locale/tests/modules/locale_test/locale_test.module index c22e307..03e455d 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.module +++ b/core/modules/locale/tests/modules/locale_test/locale_test.module @@ -18,7 +18,7 @@ function locale_test_system_info_alter(&$info, $file, $type) { // test modules should mimic a custom module. I.e. be non-hidden. if (state()->get('locale_translation_test_system_info_alter')) { if ($file->name == 'locale_test' || $file->name == 'locale_test_disabled') { - // Make the module appear as unhidden. + // Don't hide the module. $info['hidden'] = FALSE; } }