diff --git a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php b/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php index 433c8c9..7f20bf6 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/ExportForm.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/Form/LocaleSettingsForm.php b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php index 6ed3195..38de178 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php @@ -108,22 +108,25 @@ 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) ->set('translation.overwrite_not_customized', FALSE) ->save(); 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/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index c846026..c01accb 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/Gettext.php b/core/modules/locale/lib/Drupal/locale/Gettext.php index 4e73c6f..cd993b3 100644 --- a/core/modules/locale/lib/Drupal/locale/Gettext.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/Locale.php b/core/modules/locale/lib/Drupal/locale/Locale.php index f4afaed..f9723fd 100644 --- a/core/modules/locale/lib/Drupal/locale/Locale.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/LocaleConfigManager.php b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php index 3c0dc57..d2e7477 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php @@ -56,27 +56,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 + * @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/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index 277c161..8fb5244 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -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/lib/Drupal/locale/LocaleTypedConfig.php b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php index c0095f1..11219ac 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ b/core/modules/locale/lib/Drupal/locale/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($definition, $name, $langcode, LocaleConfigManager $localeConfig) { + public function __construct($definition, $name, $langcode, LocaleConfigManager $locale_config) { parent::__construct($definition, $name); $this->langcode = $langcode; - $this->localeConfig = $localeConfig; + $this->localeConfig = $locale_config; } /** diff --git a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php index 4dacd6a..11074a1 100644 --- a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php @@ -54,7 +54,6 @@ class LocaleAdminPathConfigEntityConverter 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/lib/Drupal/locale/PoDatabaseReader.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php index e545fe1..6efbfc4 100644 --- a/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/PoDatabaseWriter.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php index cdcb0c0..7d2b5fe 100644 --- a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/StringBase.php b/core/modules/locale/lib/Drupal/locale/StringBase.php index 81544f0..39fe7f1 100644 --- a/core/modules/locale/lib/Drupal/locale/StringBase.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/StringDatabaseStorage.php b/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php index 72d753a..ea4f12e 100644 --- a/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/StringInterface.php b/core/modules/locale/lib/Drupal/locale/StringInterface.php index 48e8cf8..03d8410 100644 --- a/core/modules/locale/lib/Drupal/locale/StringInterface.php +++ b/core/modules/locale/lib/Drupal/locale/StringInterface.php @@ -26,7 +26,8 @@ public function getId(); * @param int $id * The string identifier. * - * @return $this + * @return Object + * $this Object */ public function setId($id); @@ -44,7 +45,8 @@ public function getVersion(); * @param string $version * Version identifier. * - * @return $this + * @return Object + * $this Object */ public function setVersion($version); @@ -62,7 +64,8 @@ public function getString(); * @param string $string * String to set as value. * - * @return $this + * @return Object + * $this Object */ public function setString($string); @@ -82,7 +85,8 @@ public function getPlurals(); * @param array $plurals * Array of strings with plural variants. * - * @return $this + * @return Object + * $this Object */ public function setPlurals($plurals); @@ -100,7 +104,8 @@ public function getStorage(); * @param \Drupal\locale\StringStorageInterface $storage * The storage to use for this string. * - * @return $this + * @return Object + * $this Object */ public function setStorage($storage); @@ -136,7 +141,8 @@ public function isTranslation(); * @param bool $override * (optional) Whether to override already set fields, defaults to TRUE. * - * @return $this + * @return Object + * $this Object */ public function setValues(array $values, $override = TRUE); @@ -181,16 +187,17 @@ public function getLocations($check_only = FALSE); * file path in case of imported strings, configuration name for strings * that come from configuration, etc... * - * @return $this + * @return Object + * $this Object */ 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 @@ -201,7 +208,8 @@ public function hasLocation($type, $name); /** * Saves string object to storage. * - * @return $this + * @return Object + * $this Object * * @throws \Drupal\locale\StringStorageException * In case of failures, an exception is thrown. @@ -211,7 +219,8 @@ public function save(); /** * Deletes string object from storage. * - * @return $this + * @return Object + * $this Object * * @throws \Drupal\locale\StringStorageException * In case of failures, an exception is thrown. diff --git a/core/modules/locale/lib/Drupal/locale/StringStorageException.php b/core/modules/locale/lib/Drupal/locale/StringStorageException.php index 96df9a6..645fcf4 100644 --- a/core/modules/locale/lib/Drupal/locale/StringStorageException.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php index a4ee53a..f7eff5f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -23,6 +23,9 @@ class LocaleConfigTranslationTest extends WebTestBase { */ public static $modules = array('locale', 'contact'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Configuration translation', @@ -31,6 +34,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. @@ -46,7 +52,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')); @@ -60,7 +66,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/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php index 093da50..835b392 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php @@ -21,6 +21,9 @@ class LocaleContentTest extends WebTestBase { */ public static $modules = array('node', 'locale'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Content language settings', @@ -32,7 +35,7 @@ public static function getInfo() { /** * 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')); @@ -61,7 +64,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(); @@ -110,7 +113,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, @@ -135,7 +138,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. @@ -179,7 +182,6 @@ function testContentTypeDirLang() { )); } - // Check if English node does not have lang tag. $this->drupalGet('node/' . $nodes['en']->id()); $pattern = '|id="node-' . $nodes['en']->id() . '"[^<>]*lang="en"|'; @@ -206,9 +208,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/lib/Drupal/locale/Tests/LocaleExportTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php index c0ceb05..d86b3b5 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php @@ -21,6 +21,9 @@ class LocaleExportTest extends WebTestBase { */ public static $modules = array('locale'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Translation export', @@ -32,13 +35,16 @@ public static function getInfo() { /** * 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); @@ -48,7 +54,7 @@ function setUp() { /** * Test exportation of translations. */ - function testExportTranslation() { + public function testExportTranslation() { // First import some known translations. // This will also automatically enable the 'fr' language. $name = tempnam('temporary://', "po_") . '.po'; @@ -120,7 +126,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. @@ -134,7 +140,7 @@ function testExportTranslationTemplateFile() { /** * Helper function that returns a proper .po file. */ - function getPoFile() { + public function getPoFile() { return <<< EOF msgid "" msgstr "" @@ -150,10 +156,9 @@ function getPoFile() { } /** - * Helper function that returns a .po file which strings will be marked - * as customized. + * Helper function that returns a .po file which strings will be marked as customized. */ - function getCustomPoFile() { + public function getCustomPoFile() { return <<< EOF msgid "" msgstr "" @@ -174,7 +179,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/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php index d822f10..cf5927b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -21,6 +21,9 @@ class LocaleImportFunctionalTest extends WebTestBase { */ public static $modules = array('locale', 'dblog'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Translation import', @@ -32,17 +35,20 @@ public static function getInfo() { /** * 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. @@ -54,7 +60,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', @@ -73,7 +79,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', @@ -102,7 +107,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( @@ -202,7 +206,7 @@ function testStandalonePoFile() { /** * Test msgctxt context support. */ - function testLanguageContext() { + public function testLanguageContext() { // Try importing a .po file. $this->importPoFile($this->getPoFileWithContext(), array( 'langcode' => 'hr', @@ -215,7 +219,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. @@ -246,7 +250,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( @@ -316,7 +320,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; @@ -327,7 +331,7 @@ function importPoFile($contents, array $options = array()) { /** * Helper function that returns a proper .po file. */ - function getPoFile() { + public function getPoFile() { return <<< EOF msgid "" msgstr "" @@ -368,14 +372,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 "" @@ -400,7 +404,7 @@ function getBadPoFile() { /** * Helper function that returns a proper .po file for testing. */ - function getOverwritePoFile() { + public function getOverwritePoFile() { return <<< EOF msgid "" msgstr "" @@ -419,10 +423,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 "" @@ -457,7 +460,7 @@ function getCustomPoFile() { /** * Helper function that returns a .po file for testing customized strings. */ - function getCustomOverwritePoFile() { + public function getCustomOverwritePoFile() { return <<< EOF msgid "" msgstr "" @@ -481,7 +484,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 @@ -505,7 +508,7 @@ function getPoFileWithContext() { /** * Helper function that returns a .po file with an empty last item. */ - function getPoFileWithEmptyMsgstr() { + public function getPoFileWithEmptyMsgstr() { return <<< EOF msgid "" msgstr "" @@ -524,7 +527,7 @@ function getPoFileWithEmptyMsgstr() { /** * Helper function that returns a .po file with an empty last item. */ - function getPoFileWithMsgstr() { + public function getPoFileWithMsgstr() { return <<< EOF msgid "" msgstr "" @@ -546,7 +549,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/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php index 8356693..2f11484 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php @@ -22,6 +22,9 @@ class LocaleJavascriptTranslation extends WebTestBase { */ public static $modules = array('locale'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Javascript translation', @@ -29,8 +32,10 @@ public static function getInfo() { 'group' => '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/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php index 1bf1373..cee49e3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php @@ -22,6 +22,9 @@ class LocaleLibraryInfoAlterTest extends WebTestBase { */ public static $modules = array('locale'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Javascript library localization', @@ -31,10 +34,10 @@ public static function getInfo() { } /** - * 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/lib/Drupal/locale/Tests/LocalePathTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php index 0a3e64b..d76cc7b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -22,6 +22,9 @@ class LocalePathTest extends WebTestBase { */ public static $modules = array('node', 'locale', 'path', 'views'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Path language settings', @@ -30,7 +33,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -40,7 +46,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')); @@ -61,7 +67,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/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php index b1982f6..0917af3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php @@ -21,6 +21,9 @@ class LocalePluralFormatTest extends WebTestBase { */ public static $modules = array('locale'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Plural handling', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); @@ -39,7 +45,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 and enable them. $this->importPoFile($this->getPoFileWithSimplePlural(), array( @@ -140,7 +146,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 and enable them. $this->importPoFile($this->getPoFileWithSimplePlural(), array( @@ -250,7 +256,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')); @@ -275,7 +281,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; @@ -286,7 +292,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 "" @@ -309,7 +315,7 @@ function getPoFileWithSimplePlural() { /** * Returns a .po file with a complex plural formula. */ - function getPoFileWithComplexPlural() { + public function getPoFileWithComplexPlural() { return <<< EOF msgid "" msgstr "" @@ -333,7 +339,7 @@ function getPoFileWithComplexPlural() { /** * Returns a .po file with a missing plural formula. */ - function getPoFileWithMissingPlural() { + public function getPoFileWithMissingPlural() { return <<< EOF msgid "" msgstr "" @@ -350,7 +356,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/lib/Drupal/locale/Tests/LocaleStringTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php index a9b45ec..5606986 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -30,7 +30,7 @@ class LocaleStringTest extends WebTestBase { protected $storage; /** - * @return multitype:string + * {@inheritdoc} */ public static function getInfo() { return array( @@ -40,7 +40,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. $this->storage = $this->container->get('locale.storage'); @@ -54,7 +57,7 @@ function setUp() { /** * Test CRUD API. */ - function testStringCRUDAPI() { + public function testStringCRUDAPI() { // Create source string. $source = $this->buildSourceString(); $source->save(); @@ -89,7 +92,7 @@ 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. @@ -121,7 +124,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. @@ -134,7 +137,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.'); @@ -149,7 +152,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 strings. $only_translated = array('untranslated' => FALSE); @@ -160,7 +163,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.'); @@ -181,7 +184,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), @@ -191,7 +194,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); @@ -202,7 +205,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/lib/Drupal/locale/Tests/LocaleTranslateStringTourTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslateStringTourTest.php index 10db3b9..f9770e7 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslateStringTourTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslateStringTourTest.php @@ -28,6 +28,9 @@ class LocaleTranslateStringTourTest extends TourTestBase { */ public static $modules = array('locale', 'tour'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Translate Interface tour tests', @@ -36,6 +39,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ protected function setUp() { parent::setUp(); $this->adminUser = $this->drupalCreateUser(array('translate interface', 'access tour', 'administer languages')); @@ -46,7 +52,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 is 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/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php index fa33010..330ae0d 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php @@ -23,7 +23,18 @@ class LocaleTranslationUiTest extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Provides meta information about this test case, such as test name. + * + * @return array + * An array of untranslated strings with the following keys: + * - name: An overview of what is tested by the class; for example, "User + * access rules". + * - description: One sentence describing the test, starting with a verb. + * - group: The human-readable name of the module ("Node", "Statistics"), or + * the human-readable name of the Drupal facility tested (e.g. "Form API" + * or "XML-RPC"). + */ public static function getInfo() { return array( 'name' => 'String translate, search and validate', @@ -33,9 +44,9 @@ public static function getInfo() { } /** - * 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); @@ -46,7 +57,7 @@ function testEnglishTranslation() { /** * Adds a language and 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. @@ -72,7 +83,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(); @@ -120,7 +131,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', @@ -204,11 +214,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. + /** + * Adds a language and checks that the JavaScript translation files are properly created and rebuilt on deletion. */ - function testJavaScriptTranslation() { + public function testJavaScriptTranslation() { $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); $this->drupalLogin($user); $config = \Drupal::config('locale.settings'); @@ -270,7 +279,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); @@ -286,7 +295,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( @@ -324,7 +333,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. @@ -466,13 +475,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), diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php index 6554886..303306d 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php @@ -21,21 +21,21 @@ class LocaleUpdateBase extends WebTestBase { * * @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 @@ class LocaleUpdateBase extends WebTestBase { */ 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. + * Setup existing translations in the database and set up the status of existing translations. */ 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', diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php index d0da24e..470e959 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateCronTest.php @@ -12,7 +12,7 @@ */ class LocaleUpdateCronTest extends LocaleUpdateBase { - protected $batch_output = array(); + protected $batchOutput = array(); /** * Modules to enable. @@ -21,6 +21,9 @@ class LocaleUpdateCronTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Update translations using cron', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - 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); @@ -39,7 +45,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/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php index 0a502b6..e763675 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php @@ -21,6 +21,9 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test_translate'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Update translations user interface', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - 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); @@ -41,7 +47,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/lib/Drupal/locale/Tests/LocaleUpdateTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php index 81a1ac6..15a4cce 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -21,6 +21,9 @@ class LocaleUpdateTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Update translations', @@ -29,7 +32,10 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + public function setUp() { parent::setUp(); module_load_include('compare.inc', 'locale'); module_load_include('fetch.inc', 'locale'); @@ -44,7 +50,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 @@ -57,7 +63,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'))); } /** @@ -74,7 +80,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. @@ -94,9 +100,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'); @@ -110,11 +116,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'); } @@ -126,12 +132,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. @@ -148,7 +154,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')); @@ -166,10 +172,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'); @@ -188,12 +194,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. @@ -218,12 +224,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'); @@ -242,12 +248,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. @@ -278,12 +284,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. @@ -310,7 +316,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); @@ -348,7 +354,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); @@ -392,7 +398,7 @@ function testEnableLanguage() { /** * Tests automatic translation import when a custom langauge is enabled. */ - 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/lib/Drupal/locale/TranslationString.php b/core/modules/locale/lib/Drupal/locale/TranslationString.php index 6d0ac05..d04ed4f 100644 --- a/core/modules/locale/lib/Drupal/locale/TranslationString.php +++ b/core/modules/locale/lib/Drupal/locale/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/lib/Drupal/locale/TranslationsStream.php b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php index 5245bd4..4a84313 100644 --- a/core/modules/locale/lib/Drupal/locale/TranslationsStream.php +++ b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php @@ -17,9 +17,9 @@ class TranslationsStream extends LocalStream { /** - * Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath() + * Implements Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath(). */ - function getDirectoryPath() { + public function getDirectoryPath() { return \Drupal::config('locale.settings')->get('translation.path'); } @@ -27,7 +27,7 @@ function getDirectoryPath() { * Implements Drupal\Core\StreamWrapper\StreamWrapperInterface::getExternalUrl(). * @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/locale.api.php b/core/modules/locale/locale.api.php index 0db2091..fde8c8e 100644 --- a/core/modules/locale/locale.api.php +++ b/core/modules/locale/locale.api.php @@ -109,7 +109,7 @@ * @param array $projects * Project data as returned by update_get_projects(). * - * @see locale_translation_project_list(). + * @see locale_translation_project_list */ function hook_locale_translation_projects_alter(&$projects) { // The translations are located at a custom translation sever. diff --git a/core/modules/locale/locale.batch.inc b/core/modules/locale/locale.batch.inc index 4e56890..31f8002 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; @@ -25,7 +25,7 @@ * @param string $langcode * Language code of the language for which to check the translation. * @param array $options - * Optional, an array with options that can have the following elements: + * An array with options that can have the following elements: * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. * - 'use_remote': Whether or not to check the remote translation file. @@ -33,7 +33,7 @@ * @param array $context * The batch context. */ -function locale_translation_batch_status_check($project, $langcode, $options = array(), &$context) { +function locale_translation_batch_status_check($project, $langcode, array $options, &$context) { $failure = $checked = FALSE; $options += array( 'finish_feedback' => TRUE, @@ -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) { diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index e93469f..d9ff321 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -43,7 +43,7 @@ function locale_translate_import_form($form, &$form_state) { $default = key($existing_languages); $language_options = array( t('Existing languages') => $existing_languages, - t('Languages not yet added') => language_admin_predefined_list() + t('Languages not yet added') => language_admin_predefined_list(), ); } @@ -101,11 +101,11 @@ function locale_translate_import_form($form, &$form_state) { ); $form['actions'] = array( - '#type' => 'actions' + '#type' => 'actions', ); $form['actions']['submit'] = array( '#type' => 'submit', - '#value' => t('Import') + '#value' => t('Import'), ); return $form; } @@ -278,7 +278,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()); @@ -610,7 +610,7 @@ function locale_translate_file_attach_properties($file, $options = array()) { * Language codes from which to delete the translation files and history. * Defaults to all languagues * - * @return boolean + * @return bool * TRUE if files are removed successfully. FALSE if one or more files could * not be deleted. */ @@ -705,7 +705,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. diff --git a/core/modules/locale/locale.compare.inc b/core/modules/locale/locale.compare.inc index dad67a8..311b6b9 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; } @@ -211,8 +211,8 @@ 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 +282,7 @@ function locale_translation_batch_status_build($projects = array(), $langcodes = } /** - * Helper function to construct batch operations checking remote translation - * status. + * Helper function to construct batch operations checking remote translation status. * * @param array $projects * Array of project names to be processed. diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index afb4047..6497c7b 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -159,7 +159,7 @@ function locale_help($path, $arg) { return $output; case 'admin/config/regional/translate/import': - $output = '

' . t('Translation files are automatically downloaded and imported when languages are added, or when modules or themes are enabled.', array('@language' => url('admin/config/regional/language'))). '

'; + $output = '

' . t('Translation files are automatically downloaded and imported when languages are added, or when modules or themes are enabled.', array('@language' => url('admin/config/regional/language'))) . '

'; $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' => 'http://localize.drupal.org', '@export' => url('admin/config/regional/translate/export'))) . '

'; $output .= '

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

'; return $output; @@ -288,6 +288,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 @@ -410,7 +411,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. * @@ -559,6 +560,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. @@ -845,7 +847,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) { @@ -872,7 +874,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()) { @@ -961,6 +963,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; @@ -1107,8 +1110,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, extracts strings wrapped in Drupal.t() and Drupal.formatPlural() and inserts them into the database. * * @param string $filepath * File name to parse. @@ -1242,7 +1244,7 @@ function _locale_invalidate_js($langcode = NULL) { } /** - * (Re-)Creates the JavaScript translation file for a language. + * Re-Creates the JavaScript translation file for a language. * * @param $langcode * The language, the translation file should be (re)created for. @@ -1265,7 +1267,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(); @@ -1350,17 +1352,21 @@ function _locale_rebuild_js($langcode = NULL) { case 'rebuilt': watchdog('locale', 'JavaScript translation file %file.js was lost.', array('%file' => $locale_javascripts[$language->id]), WATCHDOG_WARNING); - // 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': watchdog('locale', 'Created JavaScript translation file for the language %language.', array('%language' => $language->name)); return TRUE; + case 'deleted': watchdog('locale', 'Removed JavaScript translation file for the language %language because no translations currently exist for that language.', array('%language' => $language->name)); return TRUE; + case 'error': watchdog('locale', 'An error occurred during creation of the JavaScript translation file for the language %language.', array('%language' => $language->name), WATCHDOG_ERROR); 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 c35e33a..423c889 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -74,7 +74,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; @@ -91,7 +91,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) { @@ -104,7 +104,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)), @@ -139,7 +139,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..260672d 100644 --- a/core/modules/locale/locale.translation.inc +++ b/core/modules/locale/locale.translation.inc @@ -41,7 +41,7 @@ * 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 + * @params array $project_names * Array of names of the projects to get. * * @return array @@ -107,7 +107,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 +158,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. @@ -367,7 +367,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 +389,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/tests/Drupal/locale/Tests/LocaleTranslationTest.php b/core/modules/locale/tests/Drupal/locale/Tests/LocaleTranslationTest.php index 34c24a8..a042516 100644 --- a/core/modules/locale/tests/Drupal/locale/Tests/LocaleTranslationTest.php +++ b/core/modules/locale/tests/Drupal/locale/Tests/LocaleTranslationTest.php @@ -32,6 +32,18 @@ class LocaleTranslationTest extends UnitTestCase { */ protected $languageManager; + /** + * Provides meta information about this test case, such as test name. + * + * @return array + * An array of untranslated strings with the following keys: + * - name: An overview of what is tested by the class; for example, "User + * access rules". + * - description: One sentence describing the test, starting with a verb. + * - group: The human-readable name of the module ("Node", "Statistics"), or + * the human-readable name of the Drupal facility tested (e.g. "Form API" + * or "XML-RPC"). + */ public static function getInfo() { return array( 'name' => 'Locale translation tests', @@ -51,7 +63,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/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php b/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php index 16edc7e..056ac4b 100644 --- a/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php +++ b/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php @@ -17,6 +17,18 @@ */ class LocaleLocalTasksTest extends LocalTaskIntegrationTest { + /** + * Provides meta information about this test case, such as test name. + * + * @return array + * An array of untranslated strings with the following keys: + * - name: An overview of what is tested by the class; for example, "User + * access rules". + * - description: One sentence describing the test, starting with a verb. + * - group: The human-readable name of the module ("Node", "Statistics"), or + * the human-readable name of the Drupal facility tested (e.g. "Form API" + * or "XML-RPC"). + */ public static function getInfo() { return array( 'name' => 'Locale local tasks test', @@ -25,6 +37,9 @@ public static function getInfo() { ); } + /** + * {@inheritdoc} + */ public function setUp() { $this->directoryList = array( 'locale' => 'core/modules/locale', 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',