diff --git a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php index 7213f16..18f7ddb 100644 --- a/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php +++ b/core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php @@ -51,7 +51,6 @@ class AdminPathConfigEntityConverter extends EntityConverter { * The config factory. * @param \Drupal\Core\Routing\AdminContext $admin_context * The route admin context service. - * */ public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory, AdminContext $admin_context) { parent::__construct($entity_manager); diff --git a/core/modules/locale/locale.api.php b/core/modules/locale/locale.api.php index 7dfc6f3..bd1b479 100644 --- a/core/modules/locale/locale.api.php +++ b/core/modules/locale/locale.api.php @@ -45,7 +45,8 @@ * Multiple custom modules or themes sharing the same po file should have * matching definitions. Such as modules and sub-modules or multiple modules in * the same project/code tree. Both "interface translation project" and - * "interface translation server pattern" definitions of these modules should match. + * "interface translation server pattern" definitions of these modules should + * match. * * Example .info.yml file properties for a custom module with a po file located * on a remote translation server. @@ -109,7 +110,7 @@ * @param array $projects * Project data as returned by update_get_projects(). * - * @see locale_translation_project_list(). + * @see locale_translation_project_list() * @ingroup interface_translation_properties */ function hook_locale_translation_projects_alter(&$projects) { diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index f2e7330..fbda3e8 100644 --- a/core/modules/locale/locale.batch.inc +++ b/core/modules/locale/locale.batch.inc @@ -2,7 +2,7 @@ /** * @file - * Batch process to check the availability of remote or local po files. + * Batch process to check the availability of remote or local po files. */ use GuzzleHttp\Exception\RequestException; @@ -85,7 +85,7 @@ function locale_translation_batch_status_check($project, $langcode, $options = a /** * Batch finished callback: Set result message. * - * @param boolean $success + * @param bool $success * TRUE if batch successfully completed. * @param array $results * Batch results. @@ -93,13 +93,13 @@ function locale_translation_batch_status_check($project, $langcode, $options = a function locale_translation_batch_status_finished($success, $results) { if ($success) { if (isset($results['failed_files'])) { - if (\Drupal::moduleHandler()->moduleExists('dblog')) { - $message = format_plural(count($results['failed_files']), 'One translation file could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.', array('@url' => url('admin/reports/dblog'))); - } - else { - $message = format_plural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.'); - } - drupal_set_message($message, 'error'); + if (\Drupal::moduleHandler()->moduleExists('dblog')) { + $message = format_plural(count($results['failed_files']), 'One translation file could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.', array('@url' => url('admin/reports/dblog'))); + } + else { + $message = format_plural(count($results['failed_files']), 'One translation files could not be checked. See the log for details.', '@count translation files could not be checked. See the log for details.'); + } + drupal_set_message($message, 'error'); } if (isset($results['files'])) { drupal_set_message(format_plural( @@ -201,9 +201,9 @@ function locale_translation_batch_fetch_import($project, $langcode, $options, &$ /** * Batch finished callback: Set result message. * - * @param boolean $success + * @param bool $success * TRUE if batch successfully completed. - * @param array + * @param array $results * Batch results. */ function locale_translation_batch_fetch_finished($success, $results) { @@ -220,7 +220,7 @@ function locale_translation_batch_fetch_finished($success, $results) { * @param string $uri * URI of remote file. * - * @return array|boolean + * @return array|bool * Associative array of file data with the following elements: * - last_modified: Last modified timestamp of the translation file. * - (optional) location: The location of the translation file. Is only set diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index f1fe8e8..d0c8b83 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -24,7 +24,6 @@ * LOCALE_NOT_CUSTOMIZED. * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. - * * @param $force * (optional) Import all available files, even if they were imported before. * @@ -76,7 +75,7 @@ function locale_translate_batch_import_files($options, $force = FALSE) { * Defaults to all projects. * @param array $langcodes * Language codes from which to get the translation files and history. - * Defaults to all languagues + * Defaults to all languages. * * @return array * An array of interface translation files keyed by their URI. @@ -112,7 +111,6 @@ function locale_translate_get_interface_translation_files($projects = array(), $ * * @param $files * Array of file objects to import. - * * @param array $options * An array with options that can have the following elements: * - 'langcode': The language code. Optional, defaults to NULL, which means @@ -142,7 +140,7 @@ function locale_translate_batch_build($files, $options) { $operations[] = array('locale_translate_batch_import', array($file, $options)); } // Save the translation status of all files. - $operations[] = array('locale_translate_batch_import_save', array()); + $operations[] = array('locale_translate_batch_import_save', array()); // Add a final step to refresh JavaScript and configuration strings. $operations[] = array('locale_translate_batch_refresh', array()); @@ -167,10 +165,9 @@ function locale_translate_batch_build($files, $options) { * * @param object $file * A file object of the gettext file to be imported. The file object must - * contain a language parameter - * (other than LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as - * the language of the import. - * + * contain a language parameter (other than + * LanguageInterface::LANGCODE_NOT_SPECIFIED). This is used as the language of + * the import. * @param array $options * An array with options that can have the following elements: * - 'langcode': The language code. @@ -182,7 +179,6 @@ function locale_translate_batch_build($files, $options) { * LOCALE_NOT_CUSTOMIZED. * - 'message': Alternative message to display during import. Note, this must * be sanitized text. - * * @param $context * Contains a list of files imported. */ @@ -474,9 +470,9 @@ function locale_translate_file_attach_properties($file, $options = array()) { * Defaults to all projects. * @param array $langcodes * Language codes from which to delete the translation files and history. - * Defaults to all languagues + * Defaults to all languages. * - * @return boolean + * @return bool * TRUE if files are removed successfully. FALSE if one or more files could * not be deleted. */ @@ -543,10 +539,10 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar foreach ($names as $name) { $batch_names[] = $name; $i++; - // During installation the caching of configuration objects is disabled - // so it is very expensive to initialize the \Drupal::config() object on each request. - // We batch a small number of configuration object upgrades together to - // improve the overall performance of the process. + // During installation the caching of configuration objects is disabled so + // it is very expensive to initialize the \Drupal::config() object on each + // request. We batch a small number of configuration object upgrades + // together to improve the overall performance of the process. if ($i % 20 == 0) { $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes)); $batch_names = array(); @@ -571,7 +567,7 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar /** * Performs configuration translation refresh as a batch step. * - * @param string $name + * @param string $names * Name of configuration object to update. * @param array $langcodes * (optional) Array of language codes to update. Defaults to all languages. @@ -595,12 +591,12 @@ function locale_config_batch_refresh_name(array $names, array $langcodes, array /** * Finishes callback of system page locale import batch. * - * @see locale_config_batch_build() - * * @param bool $success * Information about the success of the batch import. * @param array $results * Information about the results of the batch import. + * + * @see locale_config_batch_build() */ function locale_config_batch_finished($success, array $results) { if ($success) { diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index dad67a8..a59c55f 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -114,8 +114,8 @@ function locale_translation_build_projects() { )) ->execute(); - // Invalidate the cache of translatable projects. - locale_translation_clear_cache_projects(); + // Invalidate the cache of translatable projects. + locale_translation_clear_cache_projects(); } return $projects; } @@ -193,7 +193,8 @@ function _locale_translation_prepare_project_list($data, $type) { function locale_translation_default_translation_server() { $pattern = \Drupal::config('locale.settings')->get('translation.default_server_pattern'); // An additional check is required here. During the upgrade process - // \Drupal::config()->get() returns NULL. We use the defined value as fallback. + // \Drupal::config()->get() returns NULL. We use the defined value as + // fallback. $pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN; return array( @@ -211,8 +212,9 @@ function locale_translation_default_translation_server() { * * @return array * Available sources indexed by project and language. + * + * @todo Return batch or NULL. */ -// @todo Return batch or NULL function locale_translation_check_projects($projects = array(), $langcodes = array()) { if (locale_translation_use_remote_source()) { // Retrieve the status of both remote and local translation sources by @@ -282,8 +284,7 @@ function locale_translation_batch_status_build($projects = array(), $langcodes = } /** - * Helper function to construct batch operations checking remote translation - * status. + * Constructs batch operations checking remote translation status. * * @param array $projects * Array of project names to be processed. diff --git a/core/modules/locale/locale.install b/core/modules/locale/locale.install index c62c842..7d41967 100644 --- a/core/modules/locale/locale.install +++ b/core/modules/locale/locale.install @@ -111,7 +111,8 @@ function locale_schema() { 'customized' => array( 'type' => 'int', 'not null' => TRUE, - 'default' => 0, // LOCALE_NOT_CUSTOMIZED + // LOCALE_NOT_CUSTOMIZED + 'default' => 0, 'description' => 'Boolean indicating whether the translation is custom to this site.', ), ), @@ -170,8 +171,8 @@ function locale_schema() { ), ), 'indexes' => array( - 'string_id' => array('sid'), - 'string_type' => array('sid', 'type'), + 'string_id' => array('sid'), + 'string_type' => array('sid', 'type'), ), ); diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index ea0ec44..f0a9000 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -2,7 +2,7 @@ /** * @file - * Enables the translation of the user interface to languages other than English. + * Enables the translation of the UI to languages other than English. * * When enabled, multiple languages can be added. The site interface can be * displayed in different languages, and nodes can have languages assigned. The @@ -98,7 +98,7 @@ const LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN = 'http://ftp.drupal.org/files/translations/%core/%project/%project-%version.%language.po'; /** - * The number of seconds that the translations status entry should be considered. + * The number of seconds, after which the translations status entry expires. */ const LOCALE_TRANSLATION_STATUS_TTL = 600; @@ -108,14 +108,12 @@ const LOCALE_TRANSLATION_OVERWRITE_ALL = 'all'; /** - * UI option for override of existing translations. Only override non-customized - * translations. + * UI option for override of only non-customized existing translations. */ const LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED = 'non_customized'; /** - * UI option for override of existing translations. Don't override existing - * translations. + * UI option for not overriding existing translations. */ const LOCALE_TRANSLATION_OVERWRITE_NONE = 'none'; @@ -155,13 +153,14 @@ function locale_help($route_name, RouteMatchInterface $route_match) { return $output; case 'language.admin_overview': - return '

' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report Available translation updates shows the status. Interface text can be customized in the user interface translation page.', array('!update' => \Drupal::url('locale.translate_status'), '!translate' => \Drupal::url('locale.translate_page'))) . '

'; + return '

' . t('Interface translations are automatically imported when a language is added, or when new modules or themes are enabled. The report Available translation updates shows the status. Interface text can be customized in the user interface translation page.', array('!update' => \Drupal::url('locale.translate_status'), '!translate' => \Drupal::url('locale.translate_page'))) . '

'; + case 'locale.translate_page': $output = '

' . t('This page allows a translator to search for specific translated and untranslated strings, and is used when creating or editing translations. (Note: Because translation tasks involve many strings, it may be more convenient to export strings for offline editing in a desktop Gettext translation editor.) Searches may be limited to strings in a specific language.', array('!export' => \Drupal::url('locale.translate_export'))) . '

'; return $output; case 'locale.translate_import': - $output = '

' . t('Translation files are automatically downloaded and imported when languages are added, or when modules or themes are enabled.', array('!language' => \Drupal::url('language.admin_overview'))). '

'; + $output = '

' . t('Translation files are automatically downloaded and imported when languages are added, or when modules or themes are enabled.', array('!language' => \Drupal::url('language.admin_overview'))) . '

'; $output .= '

' . t('This page allows translators to manually import translated strings contained in a Gettext Portable Object (.po) file. Manual import may be used for customized translations or for the translation of custom modules and themes. To customize translations you can download a translation file from the Drupal translation server or export translations from the site, customize the translations using a Gettext translation editor, and import the result using this page.', array('!url' => 'https://localize.drupal.org', '!export' => \Drupal::url('locale.translate_export'))) . '

'; $output .= '

' . t('Note that importing large .po files may take several minutes.') . '

'; return $output; @@ -290,6 +289,7 @@ function locale_translatable_language_list() { * @param $langcode * Optional language code to translate to a language other than * what is used to display the page. + * * @return * The numeric index of the plural variant to use for this $langcode and * $count combination or -1 if the language was not found or does not have a @@ -412,7 +412,7 @@ function locale_queue_info() { * queue data. * * @param array $data - * Queue data array containing: + * Queue data array containing: * - Function name. * - Array of function arguments. Optionally contains the batch context data. * @@ -481,7 +481,8 @@ function locale_system_update(array $components) { $projects = array_keys(locale_translation_build_projects()); if ($list = array_intersect($list, $projects)) { module_load_include('fetch.inc', 'locale'); - // Get translation status of the projects, download and update translations. + // Get translation status of the projects, download and update + // translations. $options = _locale_translation_default_update_options(); $batch = locale_translation_batch_update_build($list, array(), $options); batch_set($batch); @@ -514,7 +515,8 @@ function locale_system_remove($components) { \Drupal\locale\Locale::config()->deleteComponentTranslations($components, array_keys($language_list)); // Only when projects are removed, the translation files and records will be - // deleted. Not each disabled module will remove a project. E.g. sub modules. + // deleted. Not each disabled module will remove a project, e.g., sub + // modules. $projects = array_keys(locale_translation_get_projects()); if ($list = array_intersect($list, $projects)) { locale_translation_file_history_delete($list); @@ -561,6 +563,7 @@ function locale_js_alter(&$javascript) { * * @param array $files * An array of local file paths. + * * @return string|null * The filepath to the translation file or NULL if no translation is * applicable. @@ -693,7 +696,7 @@ function locale_form_language_admin_overview_form_alter(&$form, &$form_state) { } /** - * Implements hook_form_FORM_ID_alter() for language_admin_add_form((). + * Implements hook_form_FORM_ID_alter() for language_admin_add_form(). */ function locale_form_language_admin_add_form_alter(&$form, &$form_state) { $form['predefined_submit']['#submit'][] = 'locale_form_language_admin_add_form_alter_submit'; @@ -799,7 +802,7 @@ function locale_system_file_system_settings_submit(&$form, $form_state) { } /** - * Implements hook_preprocess_HOOK() for node templates. + * Implements hook_preprocess_HOOK() for node.html.twig. */ function locale_preprocess_node(&$variables) { if ($variables['node']->language()->id != LanguageInterface::LANGCODE_NOT_SPECIFIED) { @@ -847,7 +850,7 @@ function locale_translation_get_file_history() { * @param object $file * Object representing the file just imported. * - * @return integer + * @return int * FALSE on failure. Otherwise SAVED_NEW or SAVED_UPDATED. */ function locale_translation_update_file_history($file) { @@ -874,7 +877,7 @@ function locale_translation_update_file_history($file) { * @param array $projects * Project name(s) to be deleted from the file history. If both project(s) and * language code(s) are specified the conditions will be ANDed. - * @param array $langcode + * @param array $langcodes * Language code(s) to be deleted from the file history. */ function locale_translation_file_history_delete($projects = array(), $langcodes = array()) { @@ -963,6 +966,7 @@ function locale_translation_status_save($project, $langcode, $type, $data) { } } break; + case LOCALE_TRANSLATION_CURRENT: $data->last_checked = REQUEST_TIME; $status[$project][$langcode]->timestamp = $data->timestamp; @@ -1109,8 +1113,7 @@ function _locale_strip_quotes($string) { } /** - * Parses a JavaScript file, extracts strings wrapped in Drupal.t() and - * Drupal.formatPlural() and inserts them into the database. + * Parses a JavaScript file for translatable strings and stores them. * * @param string $filepath * File name to parse. @@ -1200,7 +1203,8 @@ function _locale_parse_js_file($filepath) { $source = \Drupal::service('locale.storage')->findString($match); if (!$source) { - // We don't have the source string yet, thus we insert it into the database. + // We don't have the source string yet, thus we insert it into the + // database. $source = \Drupal::service('locale.storage')->createString($match); } @@ -1267,7 +1271,7 @@ function _locale_rebuild_js($langcode = NULL) { // Only add strings with a translation to the translations array. $conditions = array( 'type' => 'javascript', - 'language' => $language->id, + 'language' => $language->id, 'translated' => TRUE, ); $translations = array(); @@ -1296,7 +1300,8 @@ function _locale_rebuild_js($langcode = NULL) { // There is (on purpose) no front end to edit that variable. $dir = 'public://' . $config->get('javascript.directory'); - // Delete old file, if we have no translations anymore, or a different file to be saved. + // Delete old file, if we have no translations anymore, or a different file to + // be saved. $locale_javascripts = \Drupal::state()->get('locale.translation.javascript') ?: array(); $changed_hash = !isset($locale_javascripts[$language->id]) || ($locale_javascripts[$language->id] != $data_hash); if (!empty($locale_javascripts[$language->id]) && (!$data || $changed_hash)) { @@ -1353,17 +1358,21 @@ function _locale_rebuild_js($langcode = NULL) { case 'rebuilt': $logger->warning('JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id])); - // Proceed to the 'created' case as the JavaScript translation file has - // been created again. + // Proceed to the 'created' case as the JavaScript translation file has + // been created again. + case 'created': $logger->notice('Created JavaScript translation file for the language %language.', array('%language' => $language->name)); return TRUE; + case 'deleted': $logger->notice('Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name)); return TRUE; + case 'error': $logger->error('An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name)); return FALSE; + default: // No operation needed. return TRUE; diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 8a07c4c..2aefe71 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -73,7 +73,7 @@ function locale_translation_status_form($form, &$form_state) { $languages_not_found[$langcode] = $langcode; } // Translation update found for this project-language combination. - elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE ) { + elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) { $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : NULL; $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL; $recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local; @@ -90,7 +90,7 @@ function locale_translation_status_form($form, &$form_state) { $languages_not_found = array_diff($languages_not_found, $languages_update); // Build data options for the select table. - foreach($updates as $langcode => $update) { + foreach ($updates as $langcode => $update) { $title = String::checkPlain($languages[$langcode]->name); $locale_translation_update_info = array('#theme' => 'locale_translation_update_info'); foreach (array('updates', 'not_found') as $update_status) { @@ -103,7 +103,7 @@ function locale_translation_status_form($form, &$form_state) { 'class' => array('label'), 'data' => array( '#title' => $title, - '#markup' => $title + '#markup' => $title, ), ), 'status' => array('class' => array('description', 'expand', 'priority-low'), 'data' => drupal_render($locale_translation_update_info)), @@ -138,7 +138,7 @@ function locale_translation_status_form($form, &$form_state) { elseif ($status) { $empty = t('All translations up to date.'); } - else { + else { $empty = t('No translation status available. Check manually.', array('@check' => url('admin/reports/translations/check'))); } diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index fab2a21..a912989 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -9,6 +9,7 @@ * Comparison result of source files timestamps. * * Timestamp of source 1 is less than the timestamp of source 2. + * * @see _locale_translation_source_compare() */ const LOCALE_TRANSLATION_SOURCE_COMPARE_LT = -1; @@ -17,6 +18,7 @@ * Comparison result of source files timestamps. * * Timestamp of source 1 is equal to the timestamp of source 2. + * * @see _locale_translation_source_compare() */ const LOCALE_TRANSLATION_SOURCE_COMPARE_EQ = 0; @@ -25,6 +27,7 @@ * Comparison result of source files timestamps. * * Timestamp of source 1 is greater than the timestamp of source 2. + * * @see _locale_translation_source_compare() */ const LOCALE_TRANSLATION_SOURCE_COMPARE_GT = 1; @@ -41,8 +44,8 @@ * disabled this function will return the last known module state. The status * will only be updated once Update module is enabled. * - * @params array $project_names - * Array of names of the projects to get. + * @param array $project_names + * Array of names of the projects to get. * * @return array * Array of project data for translation update. @@ -107,7 +110,7 @@ function locale_translation_load_sources($projects = NULL, $langcodes = NULL) { $status = locale_translation_get_status(); // Use only the selected projects and languages for update. - foreach($projects as $project) { + foreach ($projects as $project) { foreach ($langcodes as $langcode) { $sources[$project][$langcode] = isset($status[$project][$langcode]) ? $status[$project][$langcode] : NULL; } @@ -158,7 +161,7 @@ function locale_translation_build_sources($projects = array(), $langcodes = arra * @param object $source * Translation source object. * - * @return stdClass + * @return object * Source file object of the po file, updated with: * - "uri": File name and path. * - "timestamp": Last updated time of the po file. @@ -203,8 +206,8 @@ function locale_translation_source_check_file($source) { * - "files": Array of file objects containing properties of local and remote * translation files. * Other processes can add the following properties: - * - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE and - * LOCALE_TRANSLATION_LOCAL indicate available new translations, + * - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE + * and LOCALE_TRANSLATION_LOCAL indicate available new translations, * LOCALE_TRANSLATION_CURRENT indicate that the current translation is them * most recent. "type" sorresponds with a key of the "files" array. * - "timestamp": The creation time of the "type" translation (file). @@ -367,7 +370,7 @@ function locale_cron_fill_queue() { * @param string $uri * The URI or URI pattern of the file. * - * @return boolean + * @return bool * TRUE if the $uri is a remote file. */ function _locale_translation_file_is_remote($uri) { @@ -389,7 +392,7 @@ function _locale_translation_file_is_remote($uri) { * @param object $source2 * Source object of available update. * - * @return integer + * @return int * - "LOCALE_TRANSLATION_SOURCE_COMPARE_LT": $source1 < $source2 OR $source1 * is missing. * - "LOCALE_TRANSLATION_SOURCE_COMPARE_EQ": $source1 == $source2 OR both diff --git a/core/modules/locale/src/Form/ExportForm.php b/core/modules/locale/src/Form/ExportForm.php index 70f611c..ea4a153 100644 --- a/core/modules/locale/src/Form/ExportForm.php +++ b/core/modules/locale/src/Form/ExportForm.php @@ -115,11 +115,11 @@ public function buildForm(array $form, array &$form_state) { } $form['actions'] = array( - '#type' => 'actions' + '#type' => 'actions', ); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => $this->t('Export') + '#value' => $this->t('Export'), ); return $form; } @@ -137,13 +137,13 @@ public function submitForm(array &$form, array &$form_state) { } $content_options = isset($form_state['values']['content_options']) ? $form_state['values']['content_options'] : array(); $reader = new PoDatabaseReader(); - $languageName = ''; + $language_name = ''; if ($language != NULL) { $reader->setLangcode($language->id); $reader->setOptions($content_options); $languages = $this->languageManager->getLanguages(); - $languageName = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; - $filename = $language->id .'.po'; + $language_name = isset($languages[$language->id]) ? $languages[$language->id]->name : ''; + $filename = $language->id . '.po'; } else { // Template required. @@ -155,9 +155,9 @@ public function submitForm(array &$form, array &$form_state) { $uri = tempnam('temporary://', 'po_'); $header = $reader->getHeader(); $header->setProjectName($this->config('system.site')->get('name')); - $header->setLanguageName($languageName); + $header->setLanguageName($language_name); - $writer = new PoStreamWriter; + $writer = new PoStreamWriter(); $writer->setUri($uri); $writer->setHeader($header); diff --git a/core/modules/locale/src/Form/ImportForm.php b/core/modules/locale/src/Form/ImportForm.php index f1ae6a1..544dc36 100644 --- a/core/modules/locale/src/Form/ImportForm.php +++ b/core/modules/locale/src/Form/ImportForm.php @@ -109,7 +109,7 @@ public function buildForm(array $form, array &$form_state) { '#theme' => 'file_upload_help', '#description' => $this->t('A Gettext Portable Object file.'), '#upload_validators' => $validators, - ), + ), '#size' => 50, '#upload_validators' => $validators, '#attributes' => array('class' => array('file-import-input')), @@ -145,11 +145,11 @@ public function buildForm(array $form, array &$form_state) { ); $form['actions'] = array( - '#type' => 'actions' + '#type' => 'actions', ); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => $this->t('Import') + '#value' => $this->t('Import'), ); return $form; } @@ -174,7 +174,7 @@ public function submitForm(array &$form, array &$form_state) { $language = $this->languageManager->getLanguage($form_state['values']['langcode']); if (empty($language)) { $language = new Language(array( - 'id' => $form_state['values']['langcode'] + 'id' => $form_state['values']['langcode'], )); $language = language_save($language); drupal_set_message($this->t('The language %language has been created.', array('%language' => $this->t($language->name)))); diff --git a/core/modules/locale/src/Form/LocaleSettingsForm.php b/core/modules/locale/src/Form/LocaleSettingsForm.php index 5bc2968..e1b13d0 100644 --- a/core/modules/locale/src/Form/LocaleSettingsForm.php +++ b/core/modules/locale/src/Form/LocaleSettingsForm.php @@ -108,12 +108,14 @@ public function submitForm(array &$form, array &$form_state) { ->set('translation.overwrite_not_customized', TRUE) ->save(); break; + case LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED: $config ->set('translation.overwrite_customized', FALSE) ->set('translation.overwrite_not_customized', TRUE) ->save(); break; + case LOCALE_TRANSLATION_OVERWRITE_NONE: $config ->set('translation.overwrite_customized', FALSE) @@ -122,8 +124,8 @@ public function submitForm(array &$form, array &$form_state) { break; } - // Invalidate the cached translation status when the configuration setting of - // 'use_source' changes. + // Invalidate the cached translation status when the configuration setting + // of 'use_source' changes. if ($form['use_source']['#default_value'] != $form_state['values']['use_source']) { locale_translation_clear_status(); } diff --git a/core/modules/locale/src/Form/TranslateEditForm.php b/core/modules/locale/src/Form/TranslateEditForm.php index c846026..c01accb 100644 --- a/core/modules/locale/src/Form/TranslateEditForm.php +++ b/core/modules/locale/src/Form/TranslateEditForm.php @@ -83,7 +83,7 @@ public function buildForm(array $form, array &$form_state) { '#type' => 'item', '#title' => $this->t('Singular form'), '#markup' => '' . String::checkPlain($source_array[0]) . '', - '#prefix' => '' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '' + '#prefix' => '' . $this->t('Source string (@language)', array('@language' => $this->t('Built-in English'))) . '', ); $form['strings'][$string->lid]['original_plural'] = array( '#type' => 'item', @@ -120,7 +120,7 @@ public function buildForm(array $form, array &$form_state) { '#rows' => $rows, '#default_value' => isset($translation_array[$i]) ? $translation_array[$i] : '', '#attributes' => array('lang' => $langcode), - '#prefix' => $i == 0 ? ('' . $this->t('Translated string (@language)', array('@language' => $langname)) . '') : '', + '#prefix' => $i == 0 ? ('' . $this->t('Translated string (@language)', array('@language' => $langname)) . '') : '', ); } } @@ -132,7 +132,7 @@ public function buildForm(array $form, array &$form_state) { '#rows' => $rows, '#default_value' => $translation_array[0], '#attributes' => array('lang' => $langcode), - '#prefix' => '' . $this->t('Translated string (@language)', array('@language' => $langname)) . '', + '#prefix' => '' . $this->t('Translated string (@language)', array('@language' => $langname)) . '', ); $form['strings'][$string->lid]['translations'][1] = array( '#type' => 'textarea', @@ -189,7 +189,8 @@ public function submitForm(array &$form, array &$form_state) { $existing_translation = isset($existing_translation_objects[$lid]); // Plural translations are saved in a delimited string. To be able to - // compare the new strings with the existing strings a string in the same format is created. + // compare the new strings with the existing strings a string in the same + // format is created. $new_translation_string_delimited = implode(LOCALE_PLURAL_DELIMITER, $new_translation['translations']); // Generate an imploded string without delimiter, to be able to run diff --git a/core/modules/locale/src/Form/TranslateFormBase.php b/core/modules/locale/src/Form/TranslateFormBase.php index e0e4ac2..d86027b 100644 --- a/core/modules/locale/src/Form/TranslateFormBase.php +++ b/core/modules/locale/src/Form/TranslateFormBase.php @@ -120,7 +120,7 @@ protected function translateFilterLoadStrings() { * @param bool $reset * If the list of values should be reset. * - * @return array $filter_values + * @return array * The filter values. */ protected function translateFilterValues($reset = FALSE) { diff --git a/core/modules/locale/src/Gettext.php b/core/modules/locale/src/Gettext.php index 4e73c6f..cd993b3 100644 --- a/core/modules/locale/src/Gettext.php +++ b/core/modules/locale/src/Gettext.php @@ -46,7 +46,7 @@ class Gettext { * * @see \Drupal\locale\PoDatabaseWriter */ - static function fileToDatabase($file, $options) { + public static function fileToDatabase($file, $options) { // Add the default values to the options array. $options += array( 'overwrite_options' => array(), diff --git a/core/modules/locale/src/Locale.php b/core/modules/locale/src/Locale.php index f4afaed..f9723fd 100644 --- a/core/modules/locale/src/Locale.php +++ b/core/modules/locale/src/Locale.php @@ -21,6 +21,7 @@ class Locale { * @see \Drupal\Core\TypedData\TypedDataManager::create() * * @return \Drupal\locale\LocaleConfigManager + * The typed config manager. */ public static function config() { return \Drupal::service('locale.config.typed'); diff --git a/core/modules/locale/src/LocaleConfigManager.php b/core/modules/locale/src/LocaleConfigManager.php index 5466558..ce929ae 100644 --- a/core/modules/locale/src/LocaleConfigManager.php +++ b/core/modules/locale/src/LocaleConfigManager.php @@ -55,27 +55,27 @@ class LocaleConfigManager extends TypedConfigManager { /** * Creates a new typed configuration manager. * - * @param \Drupal\Core\Config\StorageInterface $configStorage + * @param \Drupal\Core\Config\StorageInterface $config_storage * The storage object to use for reading configuration data. - * @param \Drupal\Core\Config\StorageInterface $schemaStorage + * @param \Drupal\Core\Config\StorageInterface $schema_storage * The storage object to use for reading schema data. - * @param \Drupal\Core\Config\StorageInterface $installStorage + * @param \Drupal\Core\Config\StorageInterface $install_storage * The storage object to use for reading default configuration * data. - * @param \Drupal\locale\StringStorageInterface $localeStorage + * @param \Drupal\locale\StringStorageInterface $locale_storage * The locale storage to use for reading string translations. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend to use for caching the definitions. * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory - * The configuration factory - * @param \Drupal\language\ConfigurableLanguageManagerInterface + * The configuration factory. + * @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager * The language manager. */ - public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager) { + public function __construct(StorageInterface $config_storage, StorageInterface $schema_storage, StorageInterface $install_storage, StringStorageInterface $locale_storage, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory, ConfigurableLanguageManagerInterface $language_manager) { // Note we use the install storage for the parent constructor. - parent::__construct($configStorage, $schemaStorage, $cache); - $this->installStorage = $installStorage; - $this->localeStorage = $localeStorage; + parent::__construct($config_storage, $schema_storage, $cache); + $this->installStorage = $install_storage; + $this->localeStorage = $locale_storage; $this->configFactory = $config_factory; $this->languageManager = $language_manager; } @@ -262,7 +262,7 @@ public function translateString($name, $langcode, $source, $context) { if (!isset($this->translations[$name][$langcode])) { // Preload all translations for this configuration name and language. $this->translations[$name][$langcode] = array(); - foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string){ + foreach ($this->localeStorage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => $name)) as $string) { $this->translations[$name][$langcode][$string->context][$string->source] = $string; } } diff --git a/core/modules/locale/src/LocaleLookup.php b/core/modules/locale/src/LocaleLookup.php index 277c161..960495e 100644 --- a/core/modules/locale/src/LocaleLookup.php +++ b/core/modules/locale/src/LocaleLookup.php @@ -119,7 +119,7 @@ protected function resolveCacheMiss($offset) { $this->stringStorage->createString(array( 'source' => $offset, 'context' => $this->context, - 'version' => \Drupal::VERSION + 'version' => \Drupal::VERSION, ))->addLocation('path', $this->requestUri())->save(); $value = TRUE; } @@ -129,7 +129,7 @@ protected function resolveCacheMiss($offset) { if ($value === TRUE) { $fallbacks = $this->languageManager->getFallbackCandidates($this->langcode, array('operation' => 'locale_lookup', 'data' => $offset)); if (!empty($fallbacks)) { - foreach($fallbacks as $langcode) { + foreach ($fallbacks as $langcode) { $translation = $this->stringStorage->findTranslation(array( 'language' => $langcode, 'source' => $offset, diff --git a/core/modules/locale/src/LocaleTranslation.php b/core/modules/locale/src/LocaleTranslation.php index d9a9800..717f2fa 100644 --- a/core/modules/locale/src/LocaleTranslation.php +++ b/core/modules/locale/src/LocaleTranslation.php @@ -38,7 +38,7 @@ class LocaleTranslation implements TranslatorInterface, DestructableInterface { protected $configFactory; /** - * Cached translations + * Cached translations. * * @var array * Array of \Drupal\locale\LocaleLookup objects indexed by language code diff --git a/core/modules/locale/src/LocaleTypedConfig.php b/core/modules/locale/src/LocaleTypedConfig.php index 36e39a9..a2ac763 100644 --- a/core/modules/locale/src/LocaleTypedConfig.php +++ b/core/modules/locale/src/LocaleTypedConfig.php @@ -47,13 +47,13 @@ class LocaleTypedConfig extends Element { * The configuration object name. * @param string $langcode * Language code for the source configuration data. - * @param \Drupal\locale\LocaleConfigManager $localeConfig; + * @param \Drupal\locale\LocaleConfigManager $locale_config * The locale configuration manager object. */ - public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $localeConfig) { + public function __construct(DataDefinitionInterface $definition, $name, $langcode, LocaleConfigManager $locale_config) { parent::__construct($definition, $name); $this->langcode = $langcode; - $this->localeConfig = $localeConfig; + $this->localeConfig = $locale_config; } /** @@ -108,7 +108,7 @@ protected function canTranslate($from_langcode, $to_langcode) { * \Drupal\Core\Config\Schema\ArrayElement. * @param array $options * Array with translation options that must contain the keys defined in - * \Drupal\locale\LocaleTypedConfig::translateElement() + * \Drupal\locale\LocaleTypedConfig::translateElement(). * * @return array * Configuration data translated to the requested language if available, @@ -132,7 +132,7 @@ protected function getElementTranslation($element, array $options) { * Typed configuration array element. * @param array $options * Array with translation options that must contain the keys defined in - * \Drupal\locale\LocaleTypedConfig::translateElement() + * \Drupal\locale\LocaleTypedConfig::translateElement(). * * @return array * Configuration data translated to the requested language. diff --git a/core/modules/locale/src/PoDatabaseReader.php b/core/modules/locale/src/PoDatabaseReader.php index e545fe1..6efbfc4 100644 --- a/core/modules/locale/src/PoDatabaseReader.php +++ b/core/modules/locale/src/PoDatabaseReader.php @@ -31,26 +31,26 @@ class PoDatabaseReader implements PoReaderInterface { * * @var array */ - private $_options; + private $options; /** * Language code of the language being read from the database. * * @var string */ - private $_langcode; + private $langcode; /** * Store the result of the query so it can be iterated later. * * @var resource */ - private $_result; + private $result; /** * Constructor, initializes with default options. */ - function __construct() { + public function __construct() { $this->setOptions(array()); } @@ -58,39 +58,39 @@ function __construct() { * Implements Drupal\Component\Gettext\PoMetadataInterface::getLangcode(). */ public function getLangcode() { - return $this->_langcode; + return $this->langcode; } /** * Implements Drupal\Component\Gettext\PoMetadataInterface::setLangcode(). */ public function setLangcode($langcode) { - $this->_langcode = $langcode; + $this->langcode = $langcode; } /** * Get the options used by the reader. */ - function getOptions() { - return $this->_options; + public function getOptions() { + return $this->options; } /** * Set the options for the current reader. */ - function setOptions(array $options) { + public function setOptions(array $options) { $options += array( 'customized' => FALSE, 'not_customized' => FALSE, 'not_translated' => FALSE, ); - $this->_options = $options; + $this->options = $options; } /** * Implements Drupal\Component\Gettext\PoMetadataInterface::getHeader(). */ - function getHeader() { + public function getHeader() { return new PoHeader($this->getLangcode()); } @@ -100,7 +100,7 @@ function getHeader() { * @throws Exception * Always, because you cannot set the PO header of a reader. */ - function setHeader(PoHeader $header) { + public function setHeader(PoHeader $header) { throw new \Exception('You cannot set the PO header in a reader.'); } @@ -108,8 +108,8 @@ function setHeader(PoHeader $header) { * Builds and executes a database query based on options set earlier. */ private function loadStrings() { - $langcode = $this->_langcode; - $options = $this->_options; + $langcode = $this->langcode; + $options = $this->options; $conditions = array(); if (array_sum($options) == 0) { @@ -156,21 +156,21 @@ private function loadStrings() { * Get the database result resource for the given language and options. */ private function readString() { - if (!isset($this->_result)) { - $this->_result = $this->loadStrings(); + if (!isset($this->result)) { + $this->result = $this->loadStrings(); } - return array_shift($this->_result); + return array_shift($this->result); } /** * Implements Drupal\Component\Gettext\PoReaderInterface::readItem(). */ - function readItem() { + public function readItem() { if ($string = $this->readString()) { - $values = (array)$string; - $poItem = new PoItem(); - $poItem->setFromArray($values); - return $poItem; + $values = (array) $string; + $po_item = new PoItem(); + $po_item->setFromArray($values); + return $po_item; } } diff --git a/core/modules/locale/src/PoDatabaseWriter.php b/core/modules/locale/src/PoDatabaseWriter.php index cdcb0c0..7d2b5fe 100644 --- a/core/modules/locale/src/PoDatabaseWriter.php +++ b/core/modules/locale/src/PoDatabaseWriter.php @@ -33,21 +33,21 @@ class PoDatabaseWriter implements PoWriterInterface { * * @var array */ - private $_options; + private $options; /** * Language code of the language being written to the database. * * @var string */ - private $_langcode; + private $langcode; /** * Header of the po file written to the database. * * @var \Drupal\Component\Gettext\PoHeader */ - private $_header; + private $header; /** * Associative array summarizing the number of changes done. @@ -60,12 +60,12 @@ class PoDatabaseWriter implements PoWriterInterface { * * @var array */ - private $_report; + private $report; /** * Constructor, initialize reporting array. */ - function __construct() { + public function __construct() { $this->setReport(); } @@ -73,21 +73,21 @@ function __construct() { * Implements Drupal\Component\Gettext\PoMetadataInterface::getLangcode(). */ public function getLangcode() { - return $this->_langcode; + return $this->langcode; } /** * Implements Drupal\Component\Gettext\PoMetadataInterface::setLangcode(). */ public function setLangcode($langcode) { - $this->_langcode = $langcode; + $this->langcode = $langcode; } /** * Get the report of the write operations. */ public function getReport() { - return $this->_report; + return $this->report; } /** @@ -96,7 +96,7 @@ public function getReport() { * @param array $report * Associative array with result information. */ - function setReport($report = array()) { + public function setReport($report = array()) { $report += array( 'additions' => 0, 'updates' => 0, @@ -104,20 +104,20 @@ function setReport($report = array()) { 'skips' => 0, 'strings' => array(), ); - $this->_report = $report; + $this->report = $report; } /** * Get the options used by the writer. */ - function getOptions() { - return $this->_options; + public function getOptions() { + return $this->options; } /** * Set the options for the current writer. */ - function setOptions(array $options) { + public function setOptions(array $options) { if (!isset($options['overwrite_options'])) { $options['overwrite_options'] = array(); } @@ -128,14 +128,14 @@ function setOptions(array $options) { $options += array( 'customized' => LOCALE_NOT_CUSTOMIZED, ); - $this->_options = $options; + $this->options = $options; } /** * Implements Drupal\Component\Gettext\PoMetadataInterface::getHeader(). */ - function getHeader() { - return $this->_header; + public function getHeader() { + return $this->header; } /** @@ -153,8 +153,8 @@ function getHeader() { * * @throws Exception */ - function setHeader(PoHeader $header) { - $this->_header = $header; + public function setHeader(PoHeader $header) { + $this->header = $header; $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); // Check for options. @@ -165,7 +165,7 @@ function setHeader(PoHeader $header) { $overwrite_options = $options['overwrite_options']; // Check for langcode. - $langcode = $this->_langcode; + $langcode = $this->langcode; if (empty($langcode)) { throw new \Exception('Langcode should be set before assigning a PoHeader.'); } @@ -187,10 +187,10 @@ function setHeader(PoHeader $header) { /** * Implements Drupal\Component\Gettext\PoWriterInterface::writeItem(). */ - function writeItem(PoItem $item) { + public function writeItem(PoItem $item) { if ($item->isPlural()) { - $item->setSource(join(LOCALE_PLURAL_DELIMITER, $item->getSource())); - $item->setTranslation(join(LOCALE_PLURAL_DELIMITER, $item->getTranslation())); + $item->setSource(implode(LOCALE_PLURAL_DELIMITER, $item->getSource())); + $item->setTranslation(implode(LOCALE_PLURAL_DELIMITER, $item->getTranslation())); } $this->importString($item); } @@ -216,12 +216,12 @@ public function writeItems(PoReaderInterface $reader, $count = -1) { */ private function importString(PoItem $item) { // Initialize overwrite options if not set. - $this->_options['overwrite_options'] += array( + $this->options['overwrite_options'] += array( 'not_customized' => FALSE, 'customized' => FALSE, ); - $overwrite_options = $this->_options['overwrite_options']; - $customized = $this->_options['customized']; + $overwrite_options = $this->options['overwrite_options']; + $customized = $this->options['customized']; $context = $item->getContext(); $source = $item->getSource(); @@ -229,9 +229,9 @@ private function importString(PoItem $item) { // Look up the source string and any existing translation. $strings = \Drupal::service('locale.storage')->getTranslations(array( - 'language' => $this->_langcode, + 'language' => $this->langcode, 'source' => $source, - 'context' => $context + 'context' => $context, )); $string = reset($strings); @@ -239,7 +239,7 @@ private function importString(PoItem $item) { // Skip this string unless it passes a check for dangerous code. if (!locale_string_is_safe($translation)) { watchdog('locale', 'Import of string "%string" was skipped because of disallowed or malformed HTML.', array('%string' => $translation), WATCHDOG_ERROR); - $this->_report['skips']++; + $this->report['skips']++; return 0; } elseif ($string) { @@ -247,19 +247,19 @@ private function importString(PoItem $item) { if ($string->isNew()) { // No translation in this language. $string->setValues(array( - 'language' => $this->_langcode, - 'customized' => $customized + 'language' => $this->langcode, + 'customized' => $customized, )); $string->save(); - $this->_report['additions']++; + $this->report['additions']++; } elseif ($overwrite_options[$string->customized ? 'customized' : 'not_customized']) { // Translation exists, only overwrite if instructed. $string->customized = $customized; $string->save(); - $this->_report['updates']++; + $this->report['updates']++; } - $this->_report['strings'][] = $string->getId(); + $this->report['strings'][] = $string->getId(); return $string->lid; } else { @@ -268,21 +268,21 @@ private function importString(PoItem $item) { ->save(); \Drupal::service('locale.storage')->createTranslation(array( 'lid' => $string->getId(), - 'language' => $this->_langcode, + 'language' => $this->langcode, 'translation' => $translation, 'customized' => $customized, ))->save(); - $this->_report['additions']++; - $this->_report['strings'][] = $string->getId(); + $this->report['additions']++; + $this->report['strings'][] = $string->getId(); return $string->lid; } } elseif ($string && !$string->isNew() && $overwrite_options[$string->customized ? 'customized' : 'not_customized']) { // Empty translation, remove existing if instructed. $string->delete(); - $this->_report['deletes']++; - $this->_report['strings'][] = $string->lid; + $this->report['deletes']++; + $this->report['strings'][] = $string->lid; return $string->lid; } } diff --git a/core/modules/locale/src/StringBase.php b/core/modules/locale/src/StringBase.php index 81544f0..39fe7f1 100644 --- a/core/modules/locale/src/StringBase.php +++ b/core/modules/locale/src/StringBase.php @@ -63,7 +63,7 @@ * Object or array with initial values. */ public function __construct($values = array()) { - $this->setValues((array)$values); + $this->setValues((array) $values); } /** @@ -189,7 +189,7 @@ public function save() { } else { throw new StringStorageException(format_string('The string cannot be saved because its not bound to a storage: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } return $this; @@ -205,7 +205,7 @@ public function delete() { } else { throw new StringStorageException(format_string('The string cannot be deleted because its not bound to a storage: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } } diff --git a/core/modules/locale/src/StringDatabaseStorage.php b/core/modules/locale/src/StringDatabaseStorage.php index 72d753a..ea4f12e 100644 --- a/core/modules/locale/src/StringDatabaseStorage.php +++ b/core/modules/locale/src/StringDatabaseStorage.php @@ -89,7 +89,7 @@ public function findTranslation(array $conditions) { /** * {@inheritdoc} */ - function getLocations(array $conditions = array()) { + public function getLocations(array $conditions = array()) { $query = $this->connection->select('locales_location', 'l', $this->options) ->fields('l'); foreach ($conditions as $field => $value) { @@ -199,7 +199,7 @@ public function delete($string) { } else { throw new StringStorageException(format_string('The string cannot be deleted because it lacks some key fields: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } return $this; @@ -212,8 +212,8 @@ public function deleteStrings($conditions) { $lids = $this->dbStringSelect($conditions, array('fields' => array('lid')))->execute()->fetchCol(); if ($lids) { $this->dbDelete('locales_target', array('lid' => $lids))->execute(); - $this->dbDelete('locales_source', array('lid' => $lids))->execute(); - $this->dbDelete('locales_location', array('sid' => $lids))->execute(); + $this->dbDelete('locales_source', array('lid' => $lids))->execute(); + $this->dbDelete('locales_location', array('sid' => $lids))->execute(); } } @@ -237,7 +237,7 @@ public function createString($values = array()) { public function createTranslation($values = array()) { return new TranslationString($values + array( 'storage' => $this, - 'is_new' => TRUE + 'is_new' => TRUE, )); } @@ -351,6 +351,7 @@ protected function dbStringLoad(array $conditions, array $options, $class) { * these additional ones: * - 'translation', Whether to include translation fields too. Defaults to * FALSE. + * * @return \Drupal\Core\Database\Query\Select * Query object with all the tables, fields and conditions. */ @@ -382,7 +383,7 @@ protected function dbStringSelect(array $conditions, array $options = array()) { if (isset($conditions['language'])) { // If we've got a language condition, we use it for the join. $query->$join('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", array( - ':langcode' => $conditions['language'] + ':langcode' => $conditions['language'], )); unset($conditions['language']); } @@ -481,7 +482,7 @@ protected function dbStringInsert($string) { } else { throw new StringStorageException(format_string('The string cannot be saved: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } } @@ -514,7 +515,7 @@ protected function dbStringUpdate($string) { } else { throw new StringStorageException(format_string('The string cannot be updated: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } } diff --git a/core/modules/locale/src/StringInterface.php b/core/modules/locale/src/StringInterface.php index 48e8cf8..046f414 100644 --- a/core/modules/locale/src/StringInterface.php +++ b/core/modules/locale/src/StringInterface.php @@ -132,7 +132,7 @@ public function isTranslation(); * Sets an array of values as object properties. * * @param array $values - * Array with values indexed by property name, + * Array with values indexed by property name. * @param bool $override * (optional) Whether to override already set fields, defaults to TRUE. * @@ -188,9 +188,9 @@ public function addLocation($type, $name); /** * Checks whether the string has a given location. * - * @param string $type. + * @param string $type * Location type. - * @param string $name. + * @param string $name * Location name. * * @return bool diff --git a/core/modules/locale/src/StringStorageException.php b/core/modules/locale/src/StringStorageException.php index 96df9a6..645fcf4 100644 --- a/core/modules/locale/src/StringStorageException.php +++ b/core/modules/locale/src/StringStorageException.php @@ -10,4 +10,4 @@ /** * Defines an exception thrown when storage operations fail. */ -class StringStorageException extends \Exception { } +class StringStorageException extends \Exception {} diff --git a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php index 94ec34d..8eaad50 100644 --- a/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleConfigTranslationTest.php @@ -25,6 +25,9 @@ class LocaleConfigTranslationTest extends WebTestBase { */ public static $modules = array('locale', 'contact'); + /** + * {@inheritdoc} + */ public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. @@ -40,7 +43,7 @@ public function setUp() { /** * Tests basic configuration translation. */ - function testConfigTranslation() { + public function testConfigTranslation() { // Add custom language. $langcode = 'xx'; $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface', 'administer modules', 'access site-wide contact form', 'administer contact forms')); @@ -54,7 +57,7 @@ function testConfigTranslation() { ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Set path prefix. - $edit = array( "prefix[$langcode]" => $langcode ); + $edit = array("prefix[$langcode]" => $langcode); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); // Check site name string exists and create translation for it. diff --git a/core/modules/locale/src/Tests/LocaleContentTest.php b/core/modules/locale/src/Tests/LocaleContentTest.php index a72d7a9..c0ffd60 100644 --- a/core/modules/locale/src/Tests/LocaleContentTest.php +++ b/core/modules/locale/src/Tests/LocaleContentTest.php @@ -28,7 +28,7 @@ class LocaleContentTest extends WebTestBase { /** * Verifies that machine name fields are always LTR. */ - function testMachineNameLTR() { + public function testMachineNameLTR() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages', 'administer site configuration')); @@ -57,7 +57,7 @@ function testMachineNameLTR() { /** * Test if a content type can be set to multilingual and language is present. */ - function testContentTypeLanguageConfiguration() { + public function testContentTypeLanguageConfiguration() { $type1 = $this->drupalCreateContentType(); $type2 = $this->drupalCreateContentType(); @@ -106,7 +106,7 @@ function testContentTypeLanguageConfiguration() { // Create a node. $node_title = $this->randomName(); - $node_body = $this->randomName(); + $node_body = $this->randomName(); $edit = array( 'type' => $type2->type, 'title' => $node_title, @@ -131,7 +131,7 @@ function testContentTypeLanguageConfiguration() { /** * Test if a dir and lang tags exist in node's attributes. */ - function testContentTypeDirLang() { + public function testContentTypeDirLang() { $type = $this->drupalCreateContentType(); // User to add and remove language. @@ -175,7 +175,6 @@ function testContentTypeDirLang() { )); } - // Check if English node does not have lang tag. $this->drupalGet('node/' . $nodes['en']->id()); $pattern = '|class="[^"]*node[^"]*"[^<>]*lang="en"|'; @@ -202,9 +201,9 @@ function testContentTypeDirLang() { /** - * Test filtering Node content by language. + * Test filtering Node content by language. */ - function testNodeAdminLanguageFilter() { + public function testNodeAdminLanguageFilter() { \Drupal::moduleHandler()->install(array('views')); // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'access content overview', 'administer nodes', 'bypass node access')); diff --git a/core/modules/locale/src/Tests/LocaleExportTest.php b/core/modules/locale/src/Tests/LocaleExportTest.php index be1f94f..8a2224d 100644 --- a/core/modules/locale/src/Tests/LocaleExportTest.php +++ b/core/modules/locale/src/Tests/LocaleExportTest.php @@ -26,13 +26,16 @@ class LocaleExportTest extends WebTestBase { /** * A user able to create languages and export translations. */ - protected $admin_user = NULL; + protected $adminUser = NULL; - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); + $this->drupalLogin($this->adminUser); // Copy test po files to the translations directory. file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE); @@ -42,7 +45,7 @@ function setUp() { /** * Test exportation of translations. */ - function testExportTranslation() { + public function testExportTranslation() { // First import some known translations. // This will also automatically add the 'fr' language. $name = tempnam('temporary://', "po_") . '.po'; @@ -114,7 +117,7 @@ function testExportTranslation() { /** * Test exportation of translation template file. */ - function testExportTranslationTemplateFile() { + public function testExportTranslationTemplateFile() { // Load an admin page with JavaScript so _drupal_add_library() fires at // least once and _locale_parse_js_file() gets to run at least once so that // the locales_source table gets populated with something. @@ -128,7 +131,7 @@ function testExportTranslationTemplateFile() { /** * Helper function that returns a proper .po file. */ - function getPoFile() { + public function getPoFile() { return <<< EOF msgid "" msgstr "" @@ -144,10 +147,9 @@ function getPoFile() { } /** - * Helper function that returns a .po file which strings will be marked - * as customized. + * Returns a .po file for which strings will be marked as customized. */ - function getCustomPoFile() { + public function getCustomPoFile() { return <<< EOF msgid "" msgstr "" @@ -168,7 +170,7 @@ function getCustomPoFile() { * @return string * A .po file fragment with an untranslated string. */ - function getUntranslatedString() { + public function getUntranslatedString() { return <<< EOF msgid "February" msgstr "" diff --git a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php index be3c22a..4471ea0 100644 --- a/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/src/Tests/LocaleImportFunctionalTest.php @@ -27,17 +27,20 @@ class LocaleImportFunctionalTest extends WebTestBase { /** * A user able to create languages and import translations. */ - protected $admin_user = NULL; + protected $adminUser = NULL; - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); // Copy test po files to the translations directory. file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.de.po', 'translations://', FILE_EXISTS_REPLACE); file_unmanaged_copy(drupal_get_path('module', 'locale') . '/tests/test.xx.po', 'translations://', FILE_EXISTS_REPLACE); - $this->admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); + $this->drupalLogin($this->adminUser); // Enable import of translations. By default this is disabled for automated // tests. @@ -49,7 +52,7 @@ function setUp() { /** * Test import of standalone .po files. */ - function testStandalonePoFile() { + public function testStandalonePoFile() { // Try importing a .po file. $this->importPoFile($this->getPoFile(), array( 'langcode' => 'fr', @@ -68,7 +71,6 @@ function testStandalonePoFile() { // Ensure we were redirected correctly. $this->assertEqual($this->getUrl(), url('admin/config/regional/translate', array('absolute' => TRUE)), 'Correct page redirection.'); - // Try importing a .po file with invalid tags. $this->importPoFile($this->getBadPoFile(), array( 'langcode' => 'fr', @@ -97,7 +99,6 @@ function testStandalonePoFile() { $this->assertEqual($this->getUrl(), url('admin/config/regional/translate/import', array('absolute' => TRUE)), 'Correct page redirection.'); $this->assertText(t('File to import not found.'), 'File to import not found message.'); - // Try importing a .po file with overriding strings, and ensure existing // strings are kept. $this->importPoFile($this->getOverwritePoFile(), array( @@ -197,7 +198,7 @@ function testStandalonePoFile() { /** * Test msgctxt context support. */ - function testLanguageContext() { + public function testLanguageContext() { // Try importing a .po file. $this->importPoFile($this->getPoFileWithContext(), array( 'langcode' => 'hr', @@ -210,7 +211,7 @@ function testLanguageContext() { /** * Test empty msgstr at end of .po file see #611786. */ - function testEmptyMsgstr() { + public function testEmptyMsgstr() { $langcode = 'hu'; // Try importing a .po file. @@ -241,7 +242,7 @@ function testEmptyMsgstr() { /** * Tests .po file import with configuration translation. */ - function testConfigPoFile() { + public function testConfigPoFile() { // Values for translations to assert. Config key, original string, // translation and config property name. $config_strings = array( @@ -311,7 +312,7 @@ function testConfigPoFile() { * @param $options * Additional options to pass to the translation import form. */ - function importPoFile($contents, array $options = array()) { + public function importPoFile($contents, array $options = array()) { $name = tempnam('temporary://', "po_") . '.po'; file_put_contents($name, $contents); $options['files[file]'] = $name; @@ -322,7 +323,7 @@ function importPoFile($contents, array $options = array()) { /** * Helper function that returns a proper .po file. */ - function getPoFile() { + public function getPoFile() { return <<< EOF msgid "" msgstr "" @@ -363,14 +364,14 @@ function getPoFile() { /** * Helper function that returns a empty .po file. */ - function getEmptyPoFile() { + public function getEmptyPoFile() { return ''; } /** * Helper function that returns a bad .po file. */ - function getBadPoFile() { + public function getBadPoFile() { return <<< EOF msgid "" msgstr "" @@ -395,7 +396,7 @@ function getBadPoFile() { /** * Helper function that returns a proper .po file for testing. */ - function getOverwritePoFile() { + public function getOverwritePoFile() { return <<< EOF msgid "" msgstr "" @@ -414,10 +415,9 @@ function getOverwritePoFile() { } /** - * Helper function that returns a .po file which strings will be marked - * as customized. + * Returns a .po file which strings will be marked as customized. */ - function getCustomPoFile() { + public function getCustomPoFile() { return <<< EOF msgid "" msgstr "" @@ -452,7 +452,7 @@ function getCustomPoFile() { /** * Helper function that returns a .po file for testing customized strings. */ - function getCustomOverwritePoFile() { + public function getCustomOverwritePoFile() { return <<< EOF msgid "" msgstr "" @@ -476,7 +476,7 @@ function getCustomOverwritePoFile() { /** * Helper function that returns a .po file with context. */ - function getPoFileWithContext() { + public function getPoFileWithContext() { // Croatian (code hr) is one the the languages that have a different // form for the full name and the abbreviated name for the month May. return <<< EOF @@ -500,7 +500,7 @@ function getPoFileWithContext() { /** * Helper function that returns a .po file with an empty last item. */ - function getPoFileWithEmptyMsgstr() { + public function getPoFileWithEmptyMsgstr() { return <<< EOF msgid "" msgstr "" @@ -519,7 +519,7 @@ function getPoFileWithEmptyMsgstr() { /** * Helper function that returns a .po file with an empty last item. */ - function getPoFileWithMsgstr() { + public function getPoFileWithMsgstr() { return <<< EOF msgid "" msgstr "" @@ -541,7 +541,7 @@ function getPoFileWithMsgstr() { /** * Helper function that returns a .po file with configuration translations. */ - function getPoFileWithConfig() { + public function getPoFileWithConfig() { return <<< EOF msgid "" msgstr "" diff --git a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php index f970646..0b81c55 100644 --- a/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php +++ b/core/modules/locale/src/Tests/LocaleJavascriptTranslationTest.php @@ -24,7 +24,10 @@ class LocaleJavascriptTranslationTest extends WebTestBase { */ public static $modules = array('locale'); - function testFileParsing() { + /** + * Tests file parsing. + */ + public function testFileParsing() { $filename = drupal_get_path('module', 'locale') . '/tests/locale_test.js'; // Parse the file to look for source strings. diff --git a/core/modules/locale/src/Tests/LocaleLibraryInfoAlterTest.php b/core/modules/locale/src/Tests/LocaleLibraryInfoAlterTest.php index 5645e9a..be38d29 100644 --- a/core/modules/locale/src/Tests/LocaleLibraryInfoAlterTest.php +++ b/core/modules/locale/src/Tests/LocaleLibraryInfoAlterTest.php @@ -25,10 +25,10 @@ class LocaleLibraryInfoAlterTest extends WebTestBase { public static $modules = array('locale'); /** - * Verifies that the datepicker can be localized. - * - * @see locale_library_info_alter() - */ + * Verifies that the datepicker can be localized. + * + * @see locale_library_info_alter() + */ public function testLibraryInfoAlter() { $attached['#attached']['library'][] = 'core/jquery.ui.datepicker'; drupal_render($attached); diff --git a/core/modules/locale/src/Tests/LocalePathTest.php b/core/modules/locale/src/Tests/LocalePathTest.php index 54a84c9..4876043 100644 --- a/core/modules/locale/src/Tests/LocalePathTest.php +++ b/core/modules/locale/src/Tests/LocalePathTest.php @@ -24,7 +24,10 @@ class LocalePathTest extends WebTestBase { */ public static $modules = array('node', 'locale', 'path', 'views'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -34,7 +37,7 @@ function setUp() { /** * Test if a language can be associated with a path alias. */ - function testPathLanguageConfiguration() { + public function testPathLanguageConfiguration() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'create page content', 'administer url aliases', 'create url aliases', 'access administration pages')); @@ -55,7 +58,7 @@ function testPathLanguageConfiguration() { $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Set path prefix. - $edit = array( "prefix[$langcode]" => $prefix ); + $edit = array("prefix[$langcode]" => $prefix); $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); // Check that the "xx" front page is readily available because path prefix diff --git a/core/modules/locale/src/Tests/LocalePluralFormatTest.php b/core/modules/locale/src/Tests/LocalePluralFormatTest.php index 8d992a3..7c93a02 100644 --- a/core/modules/locale/src/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/src/Tests/LocalePluralFormatTest.php @@ -23,7 +23,10 @@ class LocalePluralFormatTest extends WebTestBase { */ public static $modules = array('locale'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); @@ -33,7 +36,7 @@ function setUp() { /** * Tests locale_get_plural() and format_plural() functionality. */ - function testGetPluralFormat() { + public function testGetPluralFormat() { // Import some .po files with formulas to set up the environment. // These will also add the languages to the system. $this->importPoFile($this->getPoFileWithSimplePlural(), array( @@ -134,7 +137,7 @@ function testGetPluralFormat() { /** * Tests plural editing and export functionality. */ - function testPluralEditExport() { + public function testPluralEditExport() { // Import some .po files with formulas to set up the environment. // These will also add the languages to the system. $this->importPoFile($this->getPoFileWithSimplePlural(), array( @@ -244,7 +247,7 @@ function testPluralEditExport() { ); $this->drupalPostForm($path, $edit, t('Save translations')); - // Get the French translations. + // Get the French translations. $this->drupalPostForm('admin/config/regional/translate/export', array( 'langcode' => 'fr', ), t('Export')); @@ -269,7 +272,7 @@ function testPluralEditExport() { * @param $options * Additional options to pass to the translation import form. */ - function importPoFile($contents, array $options = array()) { + public function importPoFile($contents, array $options = array()) { $name = tempnam('temporary://', "po_") . '.po'; file_put_contents($name, $contents); $options['files[file]'] = $name; @@ -280,7 +283,7 @@ function importPoFile($contents, array $options = array()) { /** * Returns a .po file with a simple plural formula. */ - function getPoFileWithSimplePlural() { + public function getPoFileWithSimplePlural() { return <<< EOF msgid "" msgstr "" @@ -303,7 +306,7 @@ function getPoFileWithSimplePlural() { /** * Returns a .po file with a complex plural formula. */ - function getPoFileWithComplexPlural() { + public function getPoFileWithComplexPlural() { return <<< EOF msgid "" msgstr "" @@ -327,7 +330,7 @@ function getPoFileWithComplexPlural() { /** * Returns a .po file with a missing plural formula. */ - function getPoFileWithMissingPlural() { + public function getPoFileWithMissingPlural() { return <<< EOF msgid "" msgstr "" @@ -344,7 +347,7 @@ function getPoFileWithMissingPlural() { /** * Returns a .po file with a broken plural formula. */ - function getPoFileWithBrokenPlural() { + public function getPoFileWithBrokenPlural() { return <<< EOF msgid "" msgstr "" diff --git a/core/modules/locale/src/Tests/LocaleStringTest.php b/core/modules/locale/src/Tests/LocaleStringTest.php index 5b76e2e..7148d6a 100644 --- a/core/modules/locale/src/Tests/LocaleStringTest.php +++ b/core/modules/locale/src/Tests/LocaleStringTest.php @@ -31,7 +31,10 @@ class LocaleStringTest extends WebTestBase { */ protected $storage; - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. $this->storage = $this->container->get('locale.storage'); @@ -45,7 +48,7 @@ function setUp() { /** * Test CRUD API. */ - function testStringCRUDAPI() { + public function testStringCRUDAPI() { // Create source string. $source = $this->buildSourceString(); $source->save(); @@ -80,10 +83,11 @@ function testStringCRUDAPI() { // Delete translation. $translation->delete(); - $deleted = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid)); + $deleted = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid)); $this->assertFalse(isset($deleted->translation), 'Successfully deleted translation string.'); - // Create some translations and then delete string and all of its translations. + // Create some translations and then delete string and all of its + // translations. $lid = $source->lid; $this->createAllTranslations($source); $search = $this->storage->getTranslations(array('lid' => $source->lid)); @@ -112,7 +116,7 @@ function testStringCRUDAPI() { /** * Test Search API loading multiple objects. */ - function testStringSearchAPI() { + public function testStringSearchAPI() { $language_count = 3; // Strings 1 and 2 will have some common prefix. // Source 1 will have all translations, not customized. @@ -125,7 +129,7 @@ function testStringSearchAPI() { // Load all source strings. $strings = $this->storage->getStrings(array()); $this->assertEqual(count($strings), 3, 'Found 3 source strings in the database.'); - // Load all source strings matching a given string + // Load all source strings matching a given string. $filter_options['filters'] = array('source' => $prefix); $strings = $this->storage->getStrings(array(), $filter_options); $this->assertEqual(count($strings), 2, 'Found 2 strings using some string filter.'); @@ -140,7 +144,7 @@ function testStringSearchAPI() { $this->assertTrue($found && isset($found->language) && isset($found->translation) && !$found->isNew(), 'Translation found searching by source and context.'); $this->assertEqual($found->translation, $translate1[$langcode]->translation, 'Found the right translation.'); // Now try a translation not found. - $found = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source3->source, 'context' => $source3->context)); + $found = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source3->source, 'context' => $source3->context)); $this->assertTrue($found && $found->lid == $source3->lid && !isset($found->translation) && $found->isNew(), 'Translation not found but source string found.'); // Load all translations. For next queries we'll be loading only translated @@ -152,7 +156,7 @@ function testStringSearchAPI() { $translations = $this->storage->getTranslations(array('customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE)); $this->assertEqual(count($translations), $language_count, 'Retrieved all customized translations for source strings.'); - // Load all Spanish customized translations + // Load all Spanish customized translations. $translations = $this->storage->getTranslations(array('language' => 'es', 'customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE)); $this->assertEqual(count($translations), 1, 'Found only Spanish and customized translations.'); @@ -173,7 +177,7 @@ function testStringSearchAPI() { * @return \Drupal\locale\StringInterface * A locale string. */ - function buildSourceString($values = array()) { + public function buildSourceString($values = array()) { return $this->storage->createString($values += array( 'source' => $this->randomName(100), 'context' => $this->randomName(20), @@ -183,7 +187,7 @@ function buildSourceString($values = array()) { /** * Creates translations for source string and all languages. */ - function createAllTranslations($source, $values = array()) { + public function createAllTranslations($source, $values = array()) { $list = array(); foreach ($this->container->get('language_manager')->getLanguages() as $language) { $list[$language->id] = $this->createTranslation($source, $language->id, $values); @@ -194,7 +198,7 @@ function createAllTranslations($source, $values = array()) { /** * Creates single translation for source string. */ - function createTranslation($source, $langcode, $values = array()) { + public function createTranslation($source, $langcode, $values = array()) { return $this->storage->createTranslation($values + array( 'lid' => $source->lid, 'language' => $langcode, diff --git a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php index 8c2f5f3..016d90b 100644 --- a/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php +++ b/core/modules/locale/src/Tests/LocaleTranslateStringTourTest.php @@ -30,6 +30,9 @@ class LocaleTranslateStringTourTest extends TourTestBase { */ public static $modules = array('locale', 'tour'); + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); $this->adminUser = $this->drupalCreateUser(array('translate interface', 'access tour', 'administer languages')); @@ -40,7 +43,7 @@ protected function setUp() { * Tests locale tour tip availability. */ public function testTranslateStringTourTips() { - // Add Another Language so there is no missing form items + // Add another language so there are no missing form items. $edit = array(); $edit['predefined_langcode'] = 'es'; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); diff --git a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php index 9e65440..7c3bbd7 100644 --- a/core/modules/locale/src/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/src/Tests/LocaleTranslationUiTest.php @@ -28,9 +28,9 @@ class LocaleTranslationUiTest extends WebTestBase { public static $modules = array('locale'); /** - * Enable interface translation to English + * Enable interface translation to English. */ - function testEnglishTranslation() { + public function testEnglishTranslation() { $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); $this->drupalLogin($admin_user); @@ -39,9 +39,9 @@ function testEnglishTranslation() { } /** - * Adds a language and tests string translation by users with the appropriate permissions. + * Tests string translation by users with the appropriate permissions. */ - function testStringTranslation() { + public function testStringTranslation() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); // User to translate and delete string. @@ -67,7 +67,7 @@ function testStringTranslation() { t($name, array(), array('langcode' => $langcode)); // Reset locale cache. $this->container->get('string_translation')->reset(); - $this->assertRaw('"edit-languages-' . $langcode .'-weight"', 'Language code found.'); + $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.'); $this->assertText(t($name), 'Test language added.'); $this->drupalLogout(); @@ -115,7 +115,6 @@ function testStringTranslation() { $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $this->assertRaw($translation, 'Non-English translation properly saved.'); - $search = array( 'string' => $name, 'langcode' => 'en', @@ -199,11 +198,10 @@ function testStringTranslation() { $this->assertNoText(t('No strings available.'), 'The translation has been removed'); } - /* - * Adds a language and checks that the JavaScript translation files are - * properly created and rebuilt on deletion. + /** + * Tests that JavaScript translation files are properly created and rebuilt. */ - function testJavaScriptTranslation() { + public function testJavaScriptTranslation() { $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); $this->drupalLogin($user); $config = \Drupal::config('locale.settings'); @@ -264,7 +262,7 @@ function testJavaScriptTranslation() { /** * Tests the validation of the translation input. */ - function testStringValidation() { + public function testStringValidation() { // User to add language and strings. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages', 'translate interface')); $this->drupalLogin($admin_user); @@ -280,7 +278,7 @@ function testStringValidation() { $key = $this->randomName(16); $bad_translations[$key] = '<' . $key; $key = $this->randomName(16); - $bad_translations[$key] ="" . $key; + $bad_translations[$key] = "" . $key; // Add custom language. $edit = array( @@ -318,7 +316,7 @@ function testStringValidation() { /** * Tests translation search form. */ - function testStringSearch() { + public function testStringSearch() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); // User to translate and delete string. @@ -460,13 +458,13 @@ function testStringSearch() { /** * Tests that only changed strings are saved customized when edited. */ - function testUICustomizedStrings(){ + public function testUICustomizedStrings() { $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); $this->drupalLogin($user); $language = new Language(array('id' => 'de')); language_save($language); - // Create test source string + // Create test source string. $string = $this->container->get('locale.storage')->createString(array( 'source' => $this->randomName(100), 'context' => $this->randomName(20), @@ -483,7 +481,8 @@ function testUICustomizedStrings(){ // Reset locale cache. $this->container->get('string_translation')->reset(); - // Ensure non-customized translation string does appear if searching Non-customized translation. + // Ensure non-customized translation string does appear if searching + // non-customized translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', @@ -502,7 +501,8 @@ function testUICustomizedStrings(){ ); $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); - // Ensure unchanged translation string does appear if searching non-customized translation. + // Ensure unchanged translation string does appear if searching + // non-customized translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', @@ -520,7 +520,8 @@ function testUICustomizedStrings(){ ); $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); - // Ensure changed translation string does appear if searching customized translation. + // Ensure changed translation string does appear if searching customized + // translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', diff --git a/core/modules/locale/src/Tests/LocaleUpdateBase.php b/core/modules/locale/src/Tests/LocaleUpdateBase.php index a7895b9..a95b561 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/src/Tests/LocaleUpdateBase.php @@ -21,21 +21,21 @@ * * @var integer */ - protected $timestamp_old; + protected $timestampOld; /** * Timestamp for a medium aged translation. * * @var integer */ - protected $timestamp_medium; + protected $timestampMedium; /** * Timestamp for a new translation. * * @var integer */ - protected $timestamp_new; + protected $timestampNew; /** * Modules to enable. @@ -44,12 +44,15 @@ */ public static $modules = array('update', 'locale', 'locale_test'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); // Setup timestamps to identify old and new translation sources. - $this->timestamp_old = REQUEST_TIME - 300; - $this->timestamp_medium = REQUEST_TIME - 200; - $this->timestamp_new = REQUEST_TIME - 100; + $this->timestampOld = REQUEST_TIME - 300; + $this->timestampMedium = REQUEST_TIME - 200; + $this->timestampNew = REQUEST_TIME - 100; $this->timestamp_now = REQUEST_TIME; // Enable import of translations. By default this is disabled for automated @@ -91,7 +94,7 @@ protected function addLanguage($langcode) { * Path of the file relative to the public file path. * @param string $filename * Name of the file to create. - * @param integer $timestamp + * @param int $timestamp * Timestamp to set the file to. Defaults to current time. * @param array $translations * Array of source/target value translation strings. Only singular strings @@ -116,8 +119,8 @@ protected function makePoFile($path, $filename, $timestamp = NULL, $translations // Convert array of translations to Gettext source and translation strings. if ($translations) { foreach ($translations as $source => $target) { - $text .= 'msgid "'. $source . '"' . "\n"; - $text .= 'msgstr "'. $target . '"' . "\n"; + $text .= 'msgid "' . $source . '"' . "\n"; + $text .= 'msgstr "' . $target . '"' . "\n"; } } @@ -177,28 +180,27 @@ protected function setTranslationFiles() { // Setting up sets of translations for the translation files. $translations_one = array('January' => 'Januar_1', 'February' => 'Februar_1', 'March' => 'Marz_1'); - $translations_two = array( 'February' => 'Februar_2', 'March' => 'Marz_2', 'April' => 'April_2'); + $translations_two = array('February' => 'Februar_2', 'March' => 'Marz_2', 'April' => 'April_2'); $translations_three = array('April' => 'April_3', 'May' => 'Mai_3', 'June' => 'Juni_3'); // Add a number of files to the local file system to serve as remote // translation server and match the project definitions set in // locale_test_locale_translation_projects_alter(). - $this->makePoFile('remote/8.x/contrib_module_one', 'contrib_module_one-8.x-1.1.de._po', $this->timestamp_new, $translations_one); - $this->makePoFile('remote/8.x/contrib_module_two', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestamp_old, $translations_two); - $this->makePoFile('remote/8.x/contrib_module_three', 'contrib_module_three-8.x-1.0.de._po', $this->timestamp_old, $translations_three); + $this->makePoFile('remote/8.x/contrib_module_one', 'contrib_module_one-8.x-1.1.de._po', $this->timestampNew, $translations_one); + $this->makePoFile('remote/8.x/contrib_module_two', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestampOld, $translations_two); + $this->makePoFile('remote/8.x/contrib_module_three', 'contrib_module_three-8.x-1.0.de._po', $this->timestampOld, $translations_three); // Add a number of files to the local file system to serve as local // 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._po', $this->timestamp_old, $translations_one); - $this->makePoFile('local', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestamp_new, $translations_two); - $this->makePoFile('local', 'contrib_module_three-8.x-1.0.de._po', $this->timestamp_old, $translations_three); - $this->makePoFile('local', 'custom_module_one.de.po', $this->timestamp_new); + $this->makePoFile('local', 'contrib_module_one-8.x-1.1.de._po', $this->timestampOld, $translations_one); + $this->makePoFile('local', 'contrib_module_two-8.x-2.0-beta4.de._po', $this->timestampNew, $translations_two); + $this->makePoFile('local', 'contrib_module_three-8.x-1.0.de._po', $this->timestampOld, $translations_three); + $this->makePoFile('local', 'custom_module_one.de.po', $this->timestampNew); } /** - * Setup existing translations in the database and set up the status of - * existing translations. + * Sets up existing translations in the database. */ protected function setCurrentTranslations() { // Add non customized translations to the database. @@ -246,8 +248,8 @@ protected function setCurrentTranslations() { $default = array( 'langcode' => $langcode, 'uri' => '', - 'timestamp' => $this->timestamp_medium, - 'last_checked' => $this->timestamp_medium, + 'timestamp' => $this->timestampMedium, + 'last_checked' => $this->timestampMedium, ); $data[] = array( 'project' => 'contrib_module_one', @@ -279,7 +281,7 @@ protected function setCurrentTranslations() { * Checks the translation of a string. * * @param string $source - * Translation source string + * Translation source string. * @param string $translation * Translation to check. Use empty string to check for a not existing * translation. diff --git a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php index 64d3739..588b3d6 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateCronTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateCronTest.php @@ -14,7 +14,7 @@ */ class LocaleUpdateCronTest extends LocaleUpdateBase { - protected $batch_output = array(); + protected $batchOutput = array(); /** * Modules to enable. @@ -23,7 +23,10 @@ class LocaleUpdateCronTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface')); $this->drupalLogin($admin_user); @@ -33,7 +36,7 @@ function setUp() { /** * Tests interface translation update using cron. */ - function testUpdateCron() { + public function testUpdateCron() { // Set a flag to let the locale_test module replace the project data with a // set of test projects. \Drupal::state()->set('locale.test_projects_alter', TRUE); diff --git a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php index 2304aa5..f563101 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateInterfaceTest.php @@ -23,7 +23,10 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test_translate'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface')); $this->drupalLogin($admin_user); @@ -35,7 +38,7 @@ function setUp() { * Testing the Available updates summary on the side wide status page and the * Avaiable translation updates page. */ - function testInterface() { + public function testInterface() { // No language added. // Check status page and Available translation updates page. $this->drupalGet('admin/reports/status'); diff --git a/core/modules/locale/src/Tests/LocaleUpdateTest.php b/core/modules/locale/src/Tests/LocaleUpdateTest.php index 661c77b..54c4c73 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateTest.php @@ -24,7 +24,10 @@ class LocaleUpdateTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test'); - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); module_load_include('compare.inc', 'locale'); module_load_include('fetch.inc', 'locale'); @@ -39,7 +42,7 @@ function setUp() { /** * Checks if a list of translatable projects gets build. */ - function testUpdateProjects() { + public function testUpdateProjects() { module_load_include('compare.inc', 'locale'); // Make the test modules look like a normal custom module. i.e. make the @@ -52,7 +55,7 @@ function testUpdateProjects() { $projects = locale_translation_project_list(); $this->assertFalse(isset($projects['locale_test_translate']), 'Hidden module not found'); $this->assertEqual($projects['locale_test']['info']['interface translation server pattern'], 'core/modules/locale/test/test.%language.po', 'Interface translation parameter found in project info.'); - $this->assertEqual($projects['locale_test']['name'] , 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project'))); + $this->assertEqual($projects['locale_test']['name'], 'locale_test', format_string('%key found in project info.', array('%key' => 'interface translation project'))); } /** @@ -69,7 +72,7 @@ function testUpdateProjects() { * the most recent files are selected in the different check scenarios: check * for local files only, check for both local and remote files. */ - function testUpdateCheckStatus() { + public function testUpdateCheckStatus() { $config = \Drupal::config('locale.settings'); // Set a flag to let the locale_test module replace the project data with a // set of test projects. @@ -89,9 +92,9 @@ function testUpdateCheckStatus() { $this->drupalGet('admin/reports/translations/check'); $result = locale_translation_get_status(); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_one found'); - $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found'); + $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestampOld, 'Translation timestamp found'); $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found'); - $this->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); + $this->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation timestamp found'); $this->assertEqual($result['locale_test']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of locale_test found'); $this->assertEqual($result['custom_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of custom_module_one found'); @@ -105,11 +108,11 @@ function testUpdateCheckStatus() { $this->drupalGet('admin/reports/translations/check'); $result = locale_translation_get_status(); $this->assertEqual($result['contrib_module_one']['de']->type, LOCALE_TRANSLATION_REMOTE, 'Translation of contrib_module_one found'); - $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); + $this->assertEqual($result['contrib_module_one']['de']->timestamp, $this->timestampNew, 'Translation timestamp found'); $this->assertEqual($result['contrib_module_two']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_two found'); - $this->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation timestamp found'); + $this->assertEqual($result['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation timestamp found'); $this->assertEqual($result['contrib_module_three']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of contrib_module_three found'); - $this->assertEqual($result['contrib_module_three']['de']->timestamp, $this->timestamp_old, 'Translation timestamp found'); + $this->assertEqual($result['contrib_module_three']['de']->timestamp, $this->timestampOld, 'Translation timestamp found'); $this->assertEqual($result['locale_test']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of locale_test found'); $this->assertEqual($result['custom_module_one']['de']->type, LOCALE_TRANSLATION_LOCAL, 'Translation of custom_module_one found'); } @@ -121,12 +124,12 @@ function testUpdateCheckStatus() { * - Source: remote and local files * - Import overwrite: all existing translations */ - function testUpdateImportSourceRemote() { + public function testUpdateImportSourceRemote() { $config = \Drupal::config('locale.settings'); // Build the test environment. $this->setTranslationFiles(); - $this-> setCurrentTranslations(); + $this->setCurrentTranslations(); $config->set('translation.default_filename', '%project-%version.%language._po'); // Set the update conditions for this test. @@ -143,7 +146,7 @@ function testUpdateImportSourceRemote() { $this->assertRaw('', 'German language found'); $this->assertText('Updates for: Contributed module one, Contributed module two, Custom module one, Locale test', 'Updates found'); $this->assertText('Contributed module one (' . format_date($this->timestamp_now, 'html_date') . ')', 'Updates for Contrib module one'); - $this->assertText('Contributed module two (' . format_date($this->timestamp_new, 'html_date') . ')', 'Updates for Contrib module two'); + $this->assertText('Contributed module two (' . format_date($this->timestampNew, 'html_date') . ')', 'Updates for Contrib module two'); // Execute the translation update. $this->drupalPostForm('admin/reports/translations', array(), t('Update translations')); @@ -161,10 +164,10 @@ function testUpdateImportSourceRemote() { $history = locale_translation_get_file_history(); $this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestamp_now, 'Translation of contrib_module_one is imported'); $this->assertTrue($history['contrib_module_one']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_one is updated'); - $this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation of contrib_module_two is imported'); + $this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation of contrib_module_two is imported'); $this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_two is updated'); - $this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestamp_medium, 'Translation of contrib_module_three is not imported'); - $this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestamp_medium, 'Translation of contrib_module_three is not updated'); + $this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestampMedium, 'Translation of contrib_module_three is not imported'); + $this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated'); // Check whether existing translations have (not) been overwritten. $this->assertEqual(t('January', array(), array('langcode' => 'de')), 'Januar_1', 'Translation of January'); @@ -183,12 +186,12 @@ function testUpdateImportSourceRemote() { * - Source: local files only * - Import overwrite: all existing translations */ - function testUpdateImportSourceLocal() { + public function testUpdateImportSourceLocal() { $config = \Drupal::config('locale.settings'); // Build the test environment. $this->setTranslationFiles(); - $this-> setCurrentTranslations(); + $this->setCurrentTranslations(); $config->set('translation.default_filename', '%project-%version.%language._po'); // Set the update conditions for this test. @@ -213,12 +216,12 @@ function testUpdateImportSourceLocal() { // from the database. The function was called earlier during this test. drupal_static_reset('locale_translation_get_file_history'); $history = locale_translation_get_file_history(); - $this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestamp_medium, 'Translation of contrib_module_one is imported'); - $this->assertEqual($history['contrib_module_one']['de']->last_checked, $this->timestamp_medium, 'Translation of contrib_module_one is updated'); - $this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestamp_new, 'Translation of contrib_module_two is imported'); + $this->assertTrue($history['contrib_module_one']['de']->timestamp >= $this->timestampMedium, 'Translation of contrib_module_one is imported'); + $this->assertEqual($history['contrib_module_one']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_one is updated'); + $this->assertEqual($history['contrib_module_two']['de']->timestamp, $this->timestampNew, 'Translation of contrib_module_two is imported'); $this->assertTrue($history['contrib_module_two']['de']->last_checked >= $this->timestamp_now, 'Translation of contrib_module_two is updated'); - $this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestamp_medium, 'Translation of contrib_module_three is not imported'); - $this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestamp_medium, 'Translation of contrib_module_three is not updated'); + $this->assertEqual($history['contrib_module_three']['de']->timestamp, $this->timestampMedium, 'Translation of contrib_module_three is not imported'); + $this->assertEqual($history['contrib_module_three']['de']->last_checked, $this->timestampMedium, 'Translation of contrib_module_three is not updated'); // Check whether existing translations have (not) been overwritten. $this->assertEqual(t('January', array(), array('langcode' => 'de')), 'Januar_customized', 'Translation of January'); @@ -237,12 +240,12 @@ function testUpdateImportSourceLocal() { * - Source: remote and local files * - Import overwrite: only overwrite non-customized translations */ - function testUpdateImportModeNonCustomized() { + public function testUpdateImportModeNonCustomized() { $config = \Drupal::config('locale.settings'); // Build the test environment. $this->setTranslationFiles(); - $this-> setCurrentTranslations(); + $this->setCurrentTranslations(); $config->set('translation.default_filename', '%project-%version.%language._po'); // Set the test conditions. @@ -273,12 +276,12 @@ function testUpdateImportModeNonCustomized() { * - Source: remote and local files * - Import overwrite: don't overwrite any existing translation */ - function testUpdateImportModeNone() { + public function testUpdateImportModeNone() { $config = \Drupal::config('locale.settings'); // Build the test environment. $this->setTranslationFiles(); - $this-> setCurrentTranslations(); + $this->setCurrentTranslations(); $config->set('translation.default_filename', '%project-%version.%language._po'); // Set the test conditions. @@ -305,7 +308,7 @@ function testUpdateImportModeNone() { /** * Tests automatic translation import when a module is enabled. */ - function testEnableUninstallModule() { + public function testEnableUninstallModule() { // Make the hidden test modules look like a normal custom module. \Drupal::state()->set('locale.test_system_info_alter', TRUE); @@ -343,7 +346,7 @@ function testEnableUninstallModule() { * enabled modules and will import them. When a language is removed the system * will remove all translations of that langugue from the database. */ - function testEnableLanguage() { + public function testEnableLanguage() { // Make the hidden test modules look like a normal custom module. \Drupal::state()->set('locale.test_system_info_alter', TRUE); @@ -387,7 +390,7 @@ function testEnableLanguage() { /** * Tests automatic translation import when a custom langauge is added. */ - function testEnableCustomLanguage() { + public function testEnableCustomLanguage() { // Make the hidden test modules look like a normal custom module. \Drupal::state()->set('locale.test_system_info_alter', TRUE); diff --git a/core/modules/locale/src/TranslationString.php b/core/modules/locale/src/TranslationString.php index 6d0ac05..d04ed4f 100644 --- a/core/modules/locale/src/TranslationString.php +++ b/core/modules/locale/src/TranslationString.php @@ -42,18 +42,18 @@ class TranslationString extends StringBase { * * @var bool */ - protected $is_new; + protected $isNew; /** * Overrides Drupal\locale\StringBase::__construct(). */ public function __construct($values = array()) { parent::__construct($values); - if (!isset($this->is_new)) { + if (!isset($this->isNew)) { // We mark the string as not new if it is a complete translation. // This will work when loading from database, otherwise the storage // controller that creates the string object must handle it. - $this->is_new = !$this->isTranslation(); + $this->isNew = !$this->isTranslation(); } } @@ -104,7 +104,7 @@ public function setString($string) { * Implements Drupal\locale\StringInterface::isNew(). */ public function isNew() { - return $this->is_new; + return $this->isNew; } /** @@ -112,7 +112,7 @@ public function isNew() { */ public function save() { parent::save(); - $this->is_new = FALSE; + $this->isNew = FALSE; return $this; } @@ -121,7 +121,7 @@ public function save() { */ public function delete() { parent::delete(); - $this->is_new = TRUE; + $this->isNew = TRUE; return $this; } diff --git a/core/modules/locale/src/TranslationsStream.php b/core/modules/locale/src/TranslationsStream.php index 5245bd4..b00b58b 100644 --- a/core/modules/locale/src/TranslationsStream.php +++ b/core/modules/locale/src/TranslationsStream.php @@ -17,17 +17,18 @@ class TranslationsStream extends LocalStream { /** - * Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath() + * {@inheritdoc} */ - function getDirectoryPath() { + public function getDirectoryPath() { return \Drupal::config('locale.settings')->get('translation.path'); } /** - * Implements Drupal\Core\StreamWrapper\StreamWrapperInterface::getExternalUrl(). + * {@inheritdoc} + * * @throws \LogicException PO files URL should not be public. */ - function getExternalUrl() { + public function getExternalUrl() { throw new \LogicException('PO files URL should not be public.'); } } 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 4db96b8..1356168 100644 --- a/core/modules/locale/tests/modules/locale_test/locale_test.module +++ b/core/modules/locale/tests/modules/locale_test/locale_test.module @@ -48,10 +48,10 @@ function locale_test_locale_translation_projects_alter(&$projects) { $remote_url = $url . PublicStream::basePath() . '/remote/'; // Completely replace the project data with a set of test projects. - $projects = array ( - 'contrib_module_one' => array ( + $projects = array( + 'contrib_module_one' => array( 'name' => 'contrib_module_one', - 'info' => array ( + 'info' => array( 'name' => 'Contributed module one', 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', @@ -64,9 +64,9 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'project_type' => 'module', 'project_status' => TRUE, ), - 'contrib_module_two' => array ( + 'contrib_module_two' => array( 'name' => 'contrib_module_two', - 'info' => array ( + 'info' => array( 'name' => 'Contributed module two', 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', @@ -79,9 +79,9 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'project_type' => 'module', 'project_status' => TRUE, ), - 'contrib_module_three' => array ( + 'contrib_module_three' => array( 'name' => 'contrib_module_three', - 'info' => array ( + 'info' => array( 'name' => 'Contributed module three', 'interface translation server pattern' => $remote_url . '%core/%project/%project-%version.%language._po', 'package' => 'Other', @@ -94,9 +94,9 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'project_type' => 'module', 'project_status' => TRUE, ), - 'locale_test' => array ( + 'locale_test' => array( 'name' => 'locale_test', - 'info' => array ( + 'info' => array( 'name' => 'Locale test', 'interface translation project' => 'locale_test', 'interface translation server pattern' => 'core/modules/locale/tests/test.%language.po', @@ -110,9 +110,9 @@ function locale_test_locale_translation_projects_alter(&$projects) { 'project_type' => 'module', 'project_status' => TRUE, ), - 'custom_module_one' => array ( + 'custom_module_one' => array( 'name' => 'custom_module_one', - 'info' => array ( + 'info' => array( 'name' => 'Custom module one', 'interface translation project' => 'custom_module_one', 'interface translation server pattern' => 'translations://custom_module_one.%language.po', diff --git a/core/modules/locale/tests/src/LocaleLookupTest.php b/core/modules/locale/tests/src/LocaleLookupTest.php index fb5d9af..1295d7b 100644 --- a/core/modules/locale/tests/src/LocaleLookupTest.php +++ b/core/modules/locale/tests/src/LocaleLookupTest.php @@ -162,8 +162,10 @@ public function testResolveCacheMissWithFallback($langcode, $string, $context, $ switch ($langcode) { case 'pl': return array('cs', 'en'); + case 'cs': return array('en'); + default: return array(); } diff --git a/core/modules/locale/tests/src/LocaleTranslationTest.php b/core/modules/locale/tests/src/LocaleTranslationTest.php index befc3b7..e3f3f25 100644 --- a/core/modules/locale/tests/src/LocaleTranslationTest.php +++ b/core/modules/locale/tests/src/LocaleTranslationTest.php @@ -41,7 +41,7 @@ protected function setUp() { } /** - * Tests for \Drupal\locale\LocaleTranslation::destruct() + * Tests for \Drupal\locale\LocaleTranslation::destruct(). */ public function testDestruct() { $translation = new LocaleTranslation($this->storage, $this->cache, $this->lock, $this->getConfigFactoryStub(), $this->languageManager); diff --git a/core/modules/locale/tests/src/Menu/LocaleLocalTasksTest.php b/core/modules/locale/tests/src/Menu/LocaleLocalTasksTest.php index c190b85..ff8a96c 100644 --- a/core/modules/locale/tests/src/Menu/LocaleLocalTasksTest.php +++ b/core/modules/locale/tests/src/Menu/LocaleLocalTasksTest.php @@ -16,6 +16,9 @@ */ class LocaleLocalTasksTest extends LocalTaskIntegrationTest { + /** + * {@inheritdoc} + */ public function setUp() { $this->directoryList = array( 'locale' => 'core/modules/locale',