diff --git a/core/modules/locale/css/locale.admin.css b/core/modules/locale/css/locale.admin.css index 5d7b032..0ace5b5 100644 --- a/core/modules/locale/css/locale.admin.css +++ b/core/modules/locale/css/locale.admin.css @@ -7,7 +7,8 @@ float: left; /* LTR */ margin-right: 1em; /* LTR */ margin-bottom: 0; - /** + + /* * In Opera 9, DOM elements with the property of "overflow: auto" * will partially hide its contents with unnecessary scrollbars when * its immediate child is floated without an explicit width set. @@ -40,7 +41,7 @@ white-space: normal; } .locale-translate-edit-form td { - vertical-align: top + vertical-align: top; } .locale-translate-edit-form tr.changed { @@ -52,7 +53,7 @@ } .locale-translate-filter-form .form-wrapper { - margin-bottom:0; + margin-bottom: 0; } .locale-translate-edit-form table.changed { @@ -71,8 +72,7 @@ #locale-translation-status-form th.title { width: 25%; } -#locale-translation-status-form th.description { -} +/* #locale-translation-status-form th.description { } */ #locale-translation-status-form td { vertical-align: top; } 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..e600962 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/LocaleSettingsForm.php @@ -108,12 +108,14 @@ public function submitForm(array &$form, array &$form_state) { ->set('translation.overwrite_not_customized', TRUE) ->save(); break; + case LOCALE_TRANSLATION_OVERWRITE_NON_CUSTOMIZED: $config ->set('translation.overwrite_customized', FALSE) ->set('translation.overwrite_not_customized', TRUE) ->save(); break; + case LOCALE_TRANSLATION_OVERWRITE_NONE: $config ->set('translation.overwrite_customized', FALSE) @@ -122,7 +124,8 @@ public function submitForm(array &$form, array &$form_state) { break; } - // Invalidate the cached translation status when the configuration setting of + // 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 fb41d01..d6e0c88 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -82,7 +82,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', @@ -119,7 +119,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)) . '') : '', ); } } @@ -131,7 +131,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', @@ -180,7 +180,9 @@ public function submitForm(array &$form, array &$form_state) { // Preload all translations for strings in the form. $lids = array_keys($form_state['values']['strings']); $existing_translation_objects = array(); - foreach ($this->localeStorage->getTranslations(array('lid' => $lids, 'language' => $langcode, 'translated' => TRUE)) as $existing_translation_object) { + foreach ($this->localeStorage->getTranslations( + array('lid' => $lids, 'language' => $langcode, 'translated' => TRUE) + ) as $existing_translation_object) { $existing_translation_objects[$existing_translation_object->lid] = $existing_translation_object; } @@ -188,7 +190,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/Form/TranslateFormBase.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php index c5447e0..2bdfcdf 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFormBase.php @@ -88,8 +88,9 @@ protected function translateFilterLoadStrings() { // Language is sanitized to be one of the possible options in // translateFilterValues(). $conditions = array('language' => $filter_values['langcode']); - $options = array('pager limit' => 30, 'translated' => TRUE, 'untranslated' => TRUE); - + $options = array( + 'pager limit' => 30, + 'translated' => TRUE, 'untranslated' => TRUE); // Add translation status conditions and options. switch ($filter_values['translation']) { case 'translated': @@ -120,8 +121,8 @@ protected function translateFilterLoadStrings() { * * @param bool $reset * If the list of values should be reset. - * - * @return array $filter_values + * + * @return array * The filter values. */ protected function translateFilterValues($reset = FALSE) { diff --git a/core/modules/locale/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..460cc4b 100644 --- a/core/modules/locale/lib/Drupal/locale/Locale.php +++ b/core/modules/locale/lib/Drupal/locale/Locale.php @@ -13,14 +13,14 @@ class Locale { /** - * Returns the locale configuration manager service. - * - * Use the locale config manager service for creating locale-wrapped typed - * configuration objects. + * Use the locale config manager. + * + * Service for creating locale-wrapped typed configuration objects. * * @see \Drupal\Core\TypedData\TypedDataManager::create() * * @return \Drupal\locale\LocaleConfigManager + * Returns the locale configuration manager service. */ 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 353fcc6..4a9287b 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleConfigManager.php @@ -23,12 +23,12 @@ class LocaleConfigManager extends TypedConfigManager { * * @var \Drupal\Core\Config\StorageInterface */ - protected $installStorage; + protected $installstorage; /** * A string storage for reading and writing translations. */ - protected $localeStorage; + protected $localestorage; /** * Array with preloaded string translations. @@ -42,31 +42,31 @@ class LocaleConfigManager extends TypedConfigManager { * * @var \Drupal\Core\Config\ConfigFactoryInterface */ - protected $configFactory; + protected $configfactory; /** * Creates a new typed configuration manager. * - * @param \Drupal\Core\Config\StorageInterface $configStorage + * @param \Drupal\Core\Config\StorageInterface $config_storage * The storage controller object to use for reading configuration data. - * @param \Drupal\Core\Config\StorageInterface $schemaStorage + * @param \Drupal\Core\Config\StorageInterface $schema_storage * The storage controller object to use for reading schema data. - * @param \Drupal\Core\Config\StorageInterface $installStorage + * @param \Drupal\Core\Config\StorageInterface $installstorage * The storage controller object to use for reading default configuration * data. - * @param \Drupal\locale\StringStorageInterface $localeStorage + * @param \Drupal\locale\StringStorageInterface $localestorage * 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 + * @param \Drupal\Core\Config\ConfigFactoryInterface $configfactory * The configuration factory */ - public function __construct(StorageInterface $configStorage, StorageInterface $schemaStorage, StorageInterface $installStorage, StringStorageInterface $localeStorage, CacheBackendInterface $cache, ConfigFactoryInterface $config_factory) { + public function __construct(StorageInterface $config_storage, StorageInterface $schema_storage, StorageInterface $installstorage, StringStorageInterface $localestorage, CacheBackendInterface $cache, ConfigFactoryInterface $configfactory) { // Note we use the install storage for the parent constructor. - parent::__construct($configStorage, $schemaStorage, $cache); - $this->installStorage = $installStorage; - $this->localeStorage = $localeStorage; - $this->configFactory = $config_factory; + parent::__construct($config_storage, $schema_storage, $cache); + $this->installstorage = $installstorage; + $this->localestorage = $localestorage; + $this->configfactory = $configfactory; } /** @@ -80,8 +80,8 @@ public function __construct(StorageInterface $configStorage, StorageInterface $s */ public function get($name) { // Read default and current configuration data. - $default = $this->installStorage->read($name); - $updated = $this->configStorage->read($name); + $default = $this->installstorage->read($name); + $updated = $this->config_storage->read($name); // We get only the data that didn't change from default. $data = $this->compareConfigData($default, $updated); $definition = $this->getDefinition($name); @@ -133,8 +133,8 @@ protected function compareConfigData(array $default, $updated) { * Configuration data to be saved, that will be only the translated values. */ public function saveTranslationData($name, $langcode, array $data) { - $locale_name = $this->configFactory->getLanguageConfigName($langcode, $name); - $this->configStorage->write($locale_name, $data); + $locale_name = $this->configfactory->getLanguageConfigName($langcode, $name); + $this->config_storage->write($locale_name, $data); } /** @@ -146,8 +146,8 @@ public function saveTranslationData($name, $langcode, array $data) { * Language code. */ public function deleteTranslationData($name, $langcode) { - $locale_name = $this->configFactory->getLanguageConfigName($langcode, $name); - $this->configStorage->delete($locale_name); + $locale_name = $this->configfactory->getLanguageConfigName($langcode, $name); + $this->config_storage->delete($locale_name); } /** @@ -167,12 +167,12 @@ public function getComponentNames(array $components) { foreach ($components as $type => $list) { // InstallStorage::getComponentNames returns a list of folders keyed by // config name. - $names = array_merge($names, array_keys($this->installStorage->getComponentNames($type, $list))); + $names = array_merge($names, array_keys($this->installstorage->getComponentNames($type, $list))); } return $names; } else { - return $this->installStorage->listAll(); + return $this->installstorage->listAll(); } } @@ -206,7 +206,7 @@ public function deleteComponentTranslations(array $components, array $langcodes) */ public function getStringNames(array $lids) { $names = array(); - $locations = $this->localeStorage->getLocations(array('sid' => $lids, 'type' => 'configuration')); + $locations = $this->localestorage->getLocations(array('sid' => $lids, 'type' => 'configuration')); foreach ($locations as $location) { $names[$location->name] = $location->name; } @@ -221,8 +221,8 @@ public function getStringNames(array $lids) { */ public function deleteLanguageTranslations($langcode) { $locale_name = ConfigFactoryInterface::LANGUAGE_CONFIG_PREFIX . '.' . $langcode . '.'; - foreach ($this->configStorage->listAll($locale_name) as $name) { - $this->configStorage->delete($name); + foreach ($this->config_storage->listAll($locale_name) as $name) { + $this->config_storage->delete($name); } } @@ -252,20 +252,24 @@ 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; } } if (!isset($this->translations[$name][$langcode][$context][$source])) { // There is no translation of the source string in this config location // to this language for this context. - if ($translation = $this->localeStorage->findTranslation(array('source' => $source, 'context' => $context, 'language' => $langcode))) { + if ($translation = $this->localestorage->findTranslation(array( + 'source' => $source, + 'context' => $context, 'language' => $langcode))) { // Look for a translation of the string. It might have one, but not // be saved in this configuration location yet. // If the string has a translation for this context to this language, // save it in the configuration location so it can be looked up faster // next time. - $this->localeStorage->createString((array) $translation) + $this->localestorage->createString((array) $translation) ->addLocation('configuration', $name) ->save(); } @@ -273,7 +277,7 @@ public function translateString($name, $langcode, $source, $context) { // No translation was found. Add the source to the configuration // location so it can be translated, and the string is faster to look // for next time. - $translation = $this->localeStorage + $translation = $this->localestorage ->createString(array('source' => $source, 'context' => $context)) ->addLocation('configuration', $name) ->save(); @@ -305,8 +309,8 @@ public function translateString($name, $langcode, $source, $context) { * A boolean indicating if a language has configuration translations. */ public function hasTranslation($name, Language $language) { - $locale_name = $this->configFactory->getLanguageConfigName($language->id, $name); - $translation = $this->configStorage->read($locale_name); + $locale_name = $this->configfactory->getLanguageConfigName($language->id, $name); + $translation = $this->config_storage->read($locale_name); return !empty($translation); } diff --git a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php index 2003e4e..e69f1ca 100644 --- a/core/modules/locale/lib/Drupal/locale/LocaleLookup.php +++ b/core/modules/locale/lib/Drupal/locale/LocaleLookup.php @@ -98,7 +98,7 @@ protected function resolveCacheMiss($offset) { $this->stringStorage->createString(array( 'source' => $offset, 'context' => $this->context, - 'version' => \Drupal::VERSION + 'version' => \Drupal::VERSION, ))->addLocation('path', request_uri())->save(); $value = TRUE; } 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 3904245..3a41a8c 100644 --- a/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php +++ b/core/modules/locale/lib/Drupal/locale/ParamConverter/LocaleAdminPathConfigEntityConverter.php @@ -40,7 +40,7 @@ class LocaleAdminPathConfigEntityConverter extends EntityConverter { /** * Constructs a new EntityConverter. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entityManager + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ public function __construct(EntityManagerInterface $entity_manager, ConfigFactoryInterface $config_factory) { diff --git a/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php b/core/modules/locale/lib/Drupal/locale/PoDatabaseReader.php index e545fe1..e58af64 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; + private function getOptions() { + return $this->options; } /** * Set the options for the current reader. */ - function setOptions(array $options) { + private 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() { + private 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) { + private 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..74dfb5a 100644 --- a/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php +++ b/core/modules/locale/lib/Drupal/locale/PoDatabaseWriter.php @@ -23,7 +23,7 @@ class PoDatabaseWriter implements PoWriterInterface { * An associative array indicating what data should be overwritten, if any. * * Elements of the array: - * - override_options + * - overrideoptions * - not_customized: boolean indicating that not customized strings should * be overwritten. * - customized: boolean indicating that customized strings should be @@ -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()) { + private 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; + private function getOptions() { + return $this->options; } /** * Set the options for the current writer. */ - function setOptions(array $options) { + private 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; + private function getHeader() { + return $this->header; } /** @@ -153,8 +153,8 @@ function getHeader() { * * @throws Exception */ - function setHeader(PoHeader $header) { - $this->_header = $header; + private 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) { + private 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 fe87ef6..2c33fd6 100644 --- a/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php +++ b/core/modules/locale/lib/Drupal/locale/StringDatabaseStorage.php @@ -92,7 +92,7 @@ public function findTranslation(array $conditions) { /** * Implements Drupal\locale\StringStorageInterface::getLocations(). */ - 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) { @@ -149,13 +149,17 @@ protected function updateLocation($string) { // Make sure that the name isn't longer than 255 characters. $name = substr($name, 0, 255); if (!$lid) { - $this->dbDelete('locales_location', array('sid' => $string->getId(), 'type' => $type, 'name' => $name)) + $this->dbDelete('locales_location', array( + 'sid' => $string->getId(), + 'type' => $type, 'name' => $name)) ->execute(); } elseif ($lid === TRUE) { // This is a new location to add, take care not to duplicate. $this->connection->merge('locales_location', $this->options) - ->keys(array('sid' => $string->getId(), 'type' => $type, 'name' => $name)) + ->keys(array( + 'sid' => $string->getId(), + 'type' => $type, 'name' => $name)) ->fields(array('version' => \Drupal::VERSION)) ->execute(); $created = TRUE; @@ -202,7 +206,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; @@ -215,8 +219,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(); } } @@ -240,7 +244,7 @@ public function createString($values = array()) { public function createTranslation($values = array()) { return new TranslationString($values + array( 'storage' => $this, - 'is_new' => TRUE + 'is_new' => TRUE, )); } @@ -349,6 +353,7 @@ protected function dbStringLoad(array $conditions, array $options, $class) { * these additional ones: * - 'translation', Whether to include translation fields too. Defaults to * FALSE. + * * @return SelectQuery * Query object with all the tables, fields and conditions. */ @@ -380,7 +385,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']); } @@ -470,7 +475,8 @@ protected function dbStringInsert($string) { } elseif ($string->isTranslation()) { $string->setValues(array('customized' => 0), FALSE); - $fields = $string->getValues(array('lid', 'language', 'translation', 'customized')); + $fields = $string->getValues(array( + 'lid', 'language', 'translation', 'customized')); } if (!empty($fields)) { return $this->connection->insert($this->dbStringTable($string), $this->options) @@ -479,7 +485,7 @@ protected function dbStringInsert($string) { } else { throw new StringStorageException(format_string('The string cannot be saved: @string', array( - '@string' => $string->getString() + '@string' => $string->getString(), ))); } } @@ -512,7 +518,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 fb9d7ea..713a7cf 100644 --- a/core/modules/locale/lib/Drupal/locale/StringInterface.php +++ b/core/modules/locale/lib/Drupal/locale/StringInterface.php @@ -66,7 +66,7 @@ public function getString(); * * @return \Drupal\locale\LocaleString * The called object. - */ + */ public function setString($string); /** @@ -87,7 +87,7 @@ public function getPlurals(); * * @return \Drupal\locale\LocaleString * The called object. - */ + */ public function setPlurals($plurals); /** @@ -106,7 +106,7 @@ public function getStorage(); * * @return \Drupal\locale\LocaleString * The called object. - */ + */ public function setStorage($storage); /** @@ -195,9 +195,9 @@ public function addLocation($type, $name); /** * Checks whether the string has a given location. * - * @param string $type. + * @param string $type * Location type. - * @param string $name. + * @param string $name * Location name. * * @return bool diff --git a/core/modules/locale/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 f7c64bf..c63b601 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleConfigTranslationTest.php @@ -23,6 +23,12 @@ class LocaleConfigTranslationTest extends WebTestBase { */ public static $modules = array('locale', 'contact'); + /** + * Configuration Translations. + * + * @return array + * Returns Configuration Translations + */ public static function getInfo() { return array( 'name' => 'Configuration translation', @@ -31,6 +37,9 @@ public static function getInfo() { ); } + /** + * Enable import of translations. + */ public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. @@ -46,25 +55,35 @@ 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')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'access administration pages', + 'translate interface', + 'administer modules', + 'access site-wide contact form', + 'administer contact forms')); $this->drupalLogin($admin_user); $name = $this->randomName(16); $edit = array( 'predefined_langcode' => 'custom', 'langcode' => $langcode, 'name' => $name, - 'direction' => '0', - ); - $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); + 'direction' => '0',); + $this->drupalPostForm('admin/config/regional/language/add', + $edit, t('Add custom language')); // Set path prefix. - $edit = array( "prefix[$langcode]" => $langcode ); - $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); + $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. - $string = $this->storage->findString(array('source' => 'Drupal', 'context' => '', 'type' => 'configuration')); + $string = $this->storage->findString(array( + 'source' => 'Drupal', + 'context' => '', + 'type' => 'configuration')); $this->assertTrue($string, 'Configuration strings have been created upon installation.'); // Translate using the UI so configuration is refreshed. @@ -74,14 +93,16 @@ function testConfigTranslation() { 'langcode' => $langcode, 'translation' => 'all', ); - $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); + $this->drupalPostForm('admin/config/regional/translate', + $search, t('Filter')); $textareas = $this->xpath('//textarea'); $textarea = current($textareas); $lid = (string) $textarea[0]['name']; $edit = array( $lid => $site_name, ); - $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); + $this->drupalPostForm('admin/config/regional/translate', + $edit, t('Save translations')); $wrapper = $this->container->get('locale.config.typed')->get('system.site'); @@ -95,7 +116,9 @@ function testConfigTranslation() { $this->assertText($site_name, 'The translated site name is displayed after translations refreshed.'); // Check default medium date format exists and create a translation for it. - $string = $this->storage->findString(array('source' => 'D, m/d/Y - H:i', 'context' => '', 'type' => 'configuration')); + $string = $this->storage->findString(array( + 'source' => 'D, m/d/Y - H:i', + 'context' => '', 'type' => 'configuration')); $this->assertTrue($string, 'Configuration date formats have been created upon installation.'); // Translate using the UI so configuration is refreshed. @@ -111,7 +134,8 @@ function testConfigTranslation() { $edit = array( $lid => 'D', ); - $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); + $this->drupalPostForm('admin/config/regional/translate', + $edit, t('Save translations')); $wrapper = $this->container->get('locale.config.typed')->get('system.date_format.medium'); @@ -123,23 +147,30 @@ function testConfigTranslation() { // Formatting the date 8 / 27 / 1985 @ 13:37 EST with pattern D should // display "Tue". $formatted_date = format_date(494015820, $type = 'medium', NULL, NULL, $langcode); - $this->assertEqual($formatted_date, 'Tue', 'Got the right formatted date using the date format translation pattern.'); + $this->assertEqual($formatted_date, 'Tue', + 'Got the right formatted date using the date format translation pattern.'); // Assert strings from image module config are not available. - $string = $this->storage->findString(array('source' => 'Medium (220x220)', 'context' => '', 'type' => 'configuration')); + $string = $this->storage->findString(array( + 'source' => 'Medium (220x220)', + 'context' => '', 'type' => 'configuration')); $this->assertFalse($string, 'Configuration strings have been created upon installation.'); // Enable the image module. $this->drupalPostForm('admin/modules', array('modules[Field types][image][enable]' => "1"), t('Save configuration')); $this->resetAll(); - $string = $this->storage->findString(array('source' => 'Medium (220x220)', 'context' => '', 'type' => 'configuration')); + $string = $this->storage->findString(array( + 'source' => 'Medium (220x220)', + 'context' => '', 'type' => 'configuration')); $this->assertTrue($string, 'Configuration strings have been created upon installation.'); $locations = $string->getLocations(); $this->assertTrue(isset($locations['configuration']) && isset($locations['configuration']['image.style.medium']), 'Configuration string has been created with the right location'); // Check the string is unique and has no translation yet. - $translations = $this->storage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => 'image.style.medium')); + $translations = $this->storage->getTranslations(array( + 'language' => $langcode, + 'type' => 'configuration', 'name' => 'image.style.medium')); $translation = reset($translations); $this->assertTrue(count($translations) == 1 && $translation->source == $string->source && empty($translation->translation), 'Got only one string for image configuration and has no translation.'); @@ -159,7 +190,9 @@ function testConfigTranslation() { $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); // Check the right single translation has been created. - $translations = $this->storage->getTranslations(array('language' => $langcode, 'type' => 'configuration', 'name' => 'image.style.medium')); + $translations = $this->storage->getTranslations(array( + 'language' => $langcode, + 'type' => 'configuration', 'name' => 'image.style.medium')); $translation = reset($translations); $this->assertTrue(count($translations) == 1 && $translation->source == $string->source && $translation->translation == $image_style_label, 'Got only one translation for image configuration.'); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php index 093da50..d82576b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleContentTest.php @@ -20,7 +20,11 @@ class LocaleContentTest extends WebTestBase { * @var array */ public static $modules = array('node', 'locale'); - + /** + * Gets info of content language settings. + * @return array + * Returns content language settings + */ public static function getInfo() { return array( 'name' => 'Content language settings', @@ -32,9 +36,13 @@ 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')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'administer content types', + 'access administration pages', + 'administer site configuration')); // Log in as admin. $this->drupalLogin($admin_user); @@ -61,14 +69,20 @@ 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(); // User to add and remove language. - $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'administer content types', + 'access administration pages')); // User to create a node. - $web_user = $this->drupalCreateUser(array("create {$type1->type} content", "create {$type2->type} content", "edit any {$type2->type} content")); + $web_user = $this->drupalCreateUser(array( + "create {$type1->type} content", + "create {$type2->type} content", + "edit any {$type2->type} content")); // Add custom language. $this->drupalLogin($admin_user); @@ -110,7 +124,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,13 +149,18 @@ 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. - $admin_user = $this->drupalCreateUser(array('administer languages', 'administer content types', 'access administration pages')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'administer content types', + 'access administration pages')); // User to create a node. - $web_user = $this->drupalCreateUser(array("create {$type->type} content", "edit own {$type->type} content")); + $web_user = $this->drupalCreateUser(array( + "create {$type->type} content", + "edit own {$type->type} content")); // Login as admin. $this->drupalLogin($admin_user); @@ -178,8 +197,6 @@ function testContentTypeDirLang() { 'promote' => NODE_PROMOTED, )); } - - // Check if English node does not have lang tag. $this->drupalGet('node/' . $nodes['en']->id()); $pattern = '|id="node-' . $nodes['en']->id() . '"[^<>]*lang="en"|'; @@ -204,14 +221,18 @@ function testContentTypeDirLang() { $this->assertNoPattern($pattern, 'The dir tag has not been assigned to the Spanish node.'); } - /** - * 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')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'access administration pages', + 'access content overview', + 'administer nodes', + 'bypass node access')); // Log in as admin. $this->drupalLogin($admin_user); diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php index c0ceb05..48e7c6c 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleExportTest.php @@ -20,7 +20,11 @@ class LocaleExportTest extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Gets info of locale translation export. + * @return array + * Returns locale translation export + */ public static function getInfo() { return array( 'name' => 'Translation export', @@ -32,13 +36,18 @@ public static function getInfo() { /** * A user able to create languages and export translations. */ - protected $admin_user = NULL; - - function setUp() { + protected $adminuser = NULL; + /** + * {@inheritdoc} + */ + protected 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 +57,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 +129,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 +143,7 @@ function testExportTranslationTemplateFile() { /** * Helper function that returns a proper .po file. */ - function getPoFile() { + public function getPoFile() { return <<< EOF msgid "" msgstr "" @@ -150,10 +159,12 @@ function getPoFile() { } /** + * Helper function. + * * 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 +185,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..11aa777 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleImportFunctionalTest.php @@ -20,7 +20,11 @@ class LocaleImportFunctionalTest extends WebTestBase { * @var array */ public static $modules = array('locale', 'dblog'); - + /** + * Gets info of translation import. + * @return array + * Returns locale translation import + */ public static function getInfo() { return array( 'name' => 'Translation import', @@ -32,17 +36,23 @@ public static function getInfo() { /** * A user able to create languages and import translations. */ - protected $admin_user = NULL; + protected $adminuser = NULL; - function setUp() { + /** + * {@inheritdoc} + */ + protected 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,17 +64,22 @@ 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', )); \Drupal::config('locale.settings'); // The import should automatically create the corresponding language. - $this->assertRaw(t('The language %language has been created.', array('%language' => 'French')), 'The language has been automatically created.'); + $this->assertRaw(t('The language %language has been created.', + array('%language' => 'French')), + 'The language has been automatically created.'); // The import should have created 8 strings. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 8, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. %number translations were added, + %update translations were updated and %delete translations were removed.', + array('%number' => 8, '%update' => 0, '%delete' => 0)), + 'The translation file was successfully imported.'); // This import should have saved plural forms to have 2 variants. $locale_plurals = \Drupal::state()->get('locale.translation.plurals') ?: array(); @@ -72,15 +87,17 @@ 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', )); // The import should have created 1 string and rejected 2. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 1, '%update' => 0, '%delete' => 0)), + 'The translation file was successfully imported.'); $skip_message = format_plural(2, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.', array('@url' => url('admin/reports/dblog'))); $this->assertRaw($skip_message, 'Unsafe strings were skipped.'); @@ -101,8 +118,6 @@ function testStandalonePoFile() { ), t('Import')); $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( @@ -110,7 +125,11 @@ function testStandalonePoFile() { )); // The import should have created 1 string. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 1, '%update' => 0, '%delete' => 0)), + 'The translation file was successfully imported.'); // Ensure string wasn't overwritten. $search = array( 'string' => 'Montag', @@ -132,7 +151,11 @@ function testStandalonePoFile() { )); // The import should have updated 2 strings. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, + %update translations were updated and %delete translations were removed.', + array('%number' => 0, '%update' => 2, '%delete' => 0)), + 'The translation file was successfully imported.'); // Ensure string was overwritten. $search = array( 'string' => 'Montag', @@ -152,7 +175,11 @@ function testStandalonePoFile() { )); // The import should have created 6 strings. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 6, '%update' => 0, '%delete' => 0)), 'The customized translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 6, '%update' => 0, '%delete' => 0)), + 'The customized translation file was successfully imported.'); // The database should now contain 6 customized strings (two imported // strings are not translated). @@ -168,7 +195,11 @@ function testStandalonePoFile() { )); // The import should have created 1 string. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The customized translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 1, '%update' => 0, '%delete' => 0)), + 'The customized translation file was successfully imported.'); // Ensure string wasn't overwritten. $search = array( 'string' => 'januari', @@ -187,7 +218,11 @@ function testStandalonePoFile() { )); // The import should have updated 2 strings. - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 2, '%delete' => 0)), 'The customized translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 0, '%update' => 2, '%delete' => 0)), + 'The customized translation file was successfully imported.'); // Ensure string was overwritten. $search = array( 'string' => 'januari', @@ -202,7 +237,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 +250,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. @@ -223,7 +258,11 @@ function testEmptyMsgstr() { 'langcode' => $langcode, )); - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 1, '%update' => 0, '%delete' => 0)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 1, '%update' => 0, '%delete' => 0)), + 'The translation file was successfully imported.'); $this->assertIdentical(t('Operations', array(), array('langcode' => $langcode)), 'Műveletek', 'String imported and translated.'); // Try importing a .po file. @@ -231,7 +270,11 @@ function testEmptyMsgstr() { 'langcode' => $langcode, 'overwrite_options[not_customized]' => TRUE, )); - $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', array('%number' => 0, '%update' => 0, '%delete' => 1)), 'The translation file was successfully imported.'); + $this->assertRaw(t('One translation file imported. + %number translations were added, %update translations were updated and + %delete translations were removed.', + array('%number' => 0, '%update' => 0, '%delete' => 1)), + 'The translation file was successfully imported.'); $str = "Operations"; $search = array( @@ -246,7 +289,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( @@ -277,7 +320,10 @@ function testConfigPoFile() { // strings to interface translation executed. $locale_storage = $this->container->get('locale.storage'); foreach ($config_strings as $config_string) { - $string = $locale_storage->findString(array('source' => $config_string[0], 'context' => '', 'type' => 'configuration')); + $string = $locale_storage->findString(array( + 'source' => $config_string[0], + 'context' => '', + 'type' => 'configuration')); $this->assertTrue($string, 'Configuration strings have been created upon installation.'); } @@ -311,12 +357,12 @@ function testConfigPoFile() { /** * Helper function: import a standalone .po file in a given language. * - * @param $contents + * @param mixed $contents * Contents of the .po file to import. - * @param $options + * @param array $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 +373,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 +414,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 +446,7 @@ function getBadPoFile() { /** * Helper function that returns a proper .po file for testing. */ - function getOverwritePoFile() { + public function getOverwritePoFile() { return <<< EOF msgid "" msgstr "" @@ -419,10 +465,12 @@ function getOverwritePoFile() { } /** - * Helper function that returns a .po file which strings will be marked + * Helper function. + * + * Helper function that returns a .po file which strings, will be marked, * as customized. */ - function getCustomPoFile() { + public function getCustomPoFile() { return <<< EOF msgid "" msgstr "" @@ -457,7 +505,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 +529,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 +553,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 +572,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 +594,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..6a3733b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleJavascriptTranslation.php @@ -21,7 +21,11 @@ class LocaleJavascriptTranslation extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Gets info of locale javascript translation. + * @return array + * Returns locale javascript translation + */ public static function getInfo() { return array( 'name' => 'Javascript translation', @@ -29,8 +33,10 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function testFileParsing() { + /** + * Adds locale Javascript file. + */ + 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..8820c5f 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleLibraryInfoAlterTest.php @@ -21,7 +21,11 @@ class LocaleLibraryInfoAlterTest extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Gets info of javascript library localization. + * @return array + * Returns locale javascript library + */ public static function getInfo() { return array( 'name' => 'Javascript library localization', @@ -31,10 +35,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 62aba31..67c32d8 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePathTest.php @@ -21,7 +21,11 @@ class LocalePathTest extends WebTestBase { * @var array */ public static $modules = array('node', 'locale', 'path', 'views'); - + /** + * Gets info of language settings. + * @return array + * Returns path to language settings. + */ public static function getInfo() { return array( 'name' => 'Path language settings', @@ -29,8 +33,10 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * {@inheritdoc} + */ + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); @@ -40,9 +46,14 @@ 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')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'create page content', + 'administer url aliases', + 'create url aliases', + 'access administration pages')); // Add custom language. $this->drupalLogin($admin_user); @@ -61,7 +72,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 @@ -128,7 +139,8 @@ function testPathLanguageConfiguration() { ); $this->container->get('path.crud')->save($edit['source'], $edit['alias'], $edit['langcode']); - // Assign a custom path alias to second node with Language::LANGCODE_NOT_SPECIFIED. + // Assign a custom path alias, + // to second node with Language::LANGCODE_NOT_SPECIFIED. $edit = array( 'source' => 'node/' . $second_node->id(), 'alias' => $custom_path, diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php index 195453a..c8df280 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php @@ -20,7 +20,11 @@ class LocalePluralFormatTest extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Get Plural Translations info. + * @return array + * Returns Plural Translations info. + */ public static function getInfo() { return array( 'name' => 'Plural handling', @@ -28,18 +32,23 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * Setup The Users Permissions. + */ + public function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer languages', 'translate interface', 'access administration pages')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'translate interface', + 'access administration pages')); $this->drupalLogin($admin_user); } /** * 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( @@ -134,7 +143,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( @@ -244,7 +253,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')); @@ -264,12 +273,12 @@ function testPluralEditExport() { /** * Imports a standalone .po file in a given language. * - * @param $contents + * @param mixed $contents * Contents of the .po file to import. - * @param $options + * @param array $options * Additional options to pass to the translation import form. */ - function importPoFile($contents, array $options = array()) { + public function importPoFile($contents, array $options = array()) { $name = tempnam('temporary://', "po_") . '.po'; file_put_contents($name, $contents); $options['files[file]'] = $name; @@ -280,7 +289,7 @@ function importPoFile($contents, array $options = array()) { /** * Returns a .po file with a simple plural formula. */ - function getPoFileWithSimplePlural() { + public function getPoFileWithSimplePlural() { return <<< EOF msgid "" msgstr "" @@ -303,7 +312,7 @@ function getPoFileWithSimplePlural() { /** * Returns a .po file with a complex plural formula. */ - function getPoFileWithComplexPlural() { + public function getPoFileWithComplexPlural() { return <<< EOF msgid "" msgstr "" @@ -327,7 +336,7 @@ function getPoFileWithComplexPlural() { /** * Returns a .po file with a missing plural formula. */ - function getPoFileWithMissingPlural() { + public function getPoFileWithMissingPlural() { return <<< EOF msgid "" msgstr "" @@ -344,7 +353,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 59993f0..3efe129 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleStringTest.php @@ -32,7 +32,10 @@ class LocaleStringTest extends WebTestBase { protected $storage; /** + * Get locale string storage. + * * @return multitype:string + * Return locale string storage info. */ public static function getInfo() { return array( @@ -41,8 +44,10 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * Setup The Local Storage Language. + */ + public function setUp() { parent::setUp(); // Add a default locale storage for all these tests. $this->storage = $this->container->get('locale.storage'); @@ -56,7 +61,7 @@ function setUp() { /** * Test CRUD API. */ - function testStringCRUDAPI() { + public function testStringCRUDAPI() { // Create source string. $source = $this->buildSourceString(); $source->save(); @@ -81,7 +86,10 @@ function testStringCRUDAPI() { $this->assertEqual($translation->customized, LOCALE_NOT_CUSTOMIZED, 'Translation created as not customized by default.'); $string1 = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid)); $this->assertEqual($string1->translation, $translation->translation, 'Successfully loaded translation by string identifier.'); - $string2 = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source->source, 'context' => $source->context)); + $string2 = $this->storage->findTranslation(array( + 'language' => $langcode, + 'source' => $source->source, + 'context' => $source->context)); $this->assertEqual($string2->translation, $translation->translation, 'Successfully loaded translation by source and context.'); $translation ->setCustomized() @@ -91,10 +99,11 @@ function testStringCRUDAPI() { // Delete translation. $translation->delete(); - $deleted = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid)); + $deleted = $this->storage->findTranslation(array('language' => $langcode, 'lid' => $source->lid)); $this->assertFalse(isset($deleted->translation), 'Successfully deleted translation string.'); - // Create some translations and then delete string and all of its translations. + // Create some translations and then, + // delete string and all of its translations. $lid = $source->lid; $this->createAllTranslations($source); $search = $this->storage->getTranslations(array('lid' => $source->lid)); @@ -123,7 +132,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. @@ -136,7 +145,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.'); @@ -147,14 +156,22 @@ function testStringSearchAPI() { $this->createAllTranslations($source2, array('customized' => LOCALE_CUSTOMIZED)); // Try quick search function with different field combinations. $langcode = 'es'; - $found = $this->storage->findTranslation(array('language' => $langcode, 'source' => $source1->source, 'context' => $source1->context)); + $found = $this->storage->findTranslation(array( + 'language' => $langcode, + 'source' => $source1->source, + 'context' => $source1->context)); $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); + // Load all translations. + // For next queries we'll be loading only translated strings. + // $only_translated = array('untranslated' => FALSE); $translations = $this->storage->getTranslations(array('translated' => TRUE)); $this->assertEqual(count($translations), 2 * $language_count, 'Created and retrieved all translations for source strings.'); @@ -162,8 +179,11 @@ 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 - $translations = $this->storage->getTranslations(array('language' => 'es', 'customized' => LOCALE_CUSTOMIZED, 'translated' => TRUE)); + // 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.'); // Load all source strings without translation (1). @@ -183,7 +203,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), @@ -193,7 +213,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 (language_list() as $language) { $list[$language->id] = $this->createTranslation($source, $language->id, $values); @@ -204,7 +224,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/LocaleTranslationUiTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php index fa33010..001830b 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleTranslationUiTest.php @@ -23,7 +23,11 @@ class LocaleTranslationUiTest extends WebTestBase { * @var array */ public static $modules = array('locale'); - + /** + * Get Translations info. + * @return array + * Returns Translations info. + */ public static function getInfo() { return array( 'name' => 'String translate, search and validate', @@ -33,9 +37,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); @@ -44,9 +48,12 @@ function testEnglishTranslation() { } /** - * Adds a language and tests string translation by users with the appropriate permissions. + * Adds a language and tests string. + * + * 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. @@ -69,11 +76,11 @@ function testStringTranslation() { ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t('%name', array('%name' => $name), array('langcode' => $langcode)); // Reset locale cache. $this->container->get('string_translation')->reset(); - $this->assertRaw('"edit-languages-' . $langcode .'-weight"', 'Language code found.'); - $this->assertText(t($name), 'Test language added.'); + $this->assertRaw('"edit-languages-' . $langcode . '-weight"', 'Language code found.'); + $this->assertText(t('%name', array('%name' => $name)), 'Test language added.'); $this->drupalLogout(); // Search for the name and translate it. @@ -119,8 +126,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', @@ -145,14 +150,14 @@ function testStringTranslation() { // Cache::deleteTags() on the tested side. drupal_static_reset('Drupal\Core\Cache\CacheBackendInterface::tagCache'); - $this->assertTrue($name != $translation && t($name, array(), array('langcode' => $langcode)) == $translation, 't() works for non-English.'); + $this->assertTrue($name != $translation && t('%name', array('%name' => $name), array(), array('langcode' => $langcode)) == $translation, 't() works for non-English.'); // Refresh the locale() cache to get fresh data from t() below. We are in // the same HTTP request and therefore t() is not refreshed by saving the // translation above. $this->container->get('string_translation')->reset(); // Now we should get the proper fresh translation from t(). - $this->assertTrue($name != $translation_to_en && t($name, array(), array('langcode' => 'en')) == $translation_to_en, 't() works for English.'); - $this->assertTrue(t($name, array(), array('langcode' => Language::LANGCODE_SYSTEM)) == $name, 't() works for Language::LANGCODE_SYSTEM.'); + $this->assertTrue($name != $translation_to_en && t('%name', array('%name' => $name), array(), array('langcode' => 'en')) == $translation_to_en, 't() works for English.'); + $this->assertTrue(t('%name', array('%name' => $name), array(), array('langcode' => Language::LANGCODE_SYSTEM)) == $name, 't() works for Language::LANGCODE_SYSTEM.'); $search = array( 'string' => $name, @@ -203,13 +208,16 @@ function testStringTranslation() { $this->drupalPostForm('admin/config/regional/translate', $search, t('Filter')); $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() { - $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); + public function testJavaScriptTranslation() { + $user = $this->drupalCreateUser(array( + 'translate interface', + 'administer languages', + 'access administration pages')); $this->drupalLogin($user); $config = \Drupal::config('locale.settings'); @@ -270,9 +278,12 @@ 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')); + $admin_user = $this->drupalCreateUser(array( + 'administer languages', + 'access administration pages', + 'translate interface')); $this->drupalLogin($admin_user); $langcode = 'xx'; // The English name for the language. This will be translated. @@ -286,7 +297,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( @@ -297,7 +308,7 @@ function testStringValidation() { ); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t('%name', array('%name' => $name), array('langcode' => $langcode)); // Reset locale cache. $search = array( 'string' => $name, @@ -324,7 +335,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. @@ -356,7 +367,7 @@ function testStringSearch() { $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); // Add string. - t($name, array(), array('langcode' => $langcode)); + t('%name', array('%name' => $name), array(), array('langcode' => $langcode)); // Reset locale cache. $this->container->get('string_translation')->reset(); $this->drupalLogout(); @@ -466,13 +477,16 @@ function testStringSearch() { /** * Tests that only changed strings are saved customized when edited. */ - function testUICustomizedStrings(){ - $user = $this->drupalCreateUser(array('translate interface', 'administer languages', 'access administration pages')); + 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), @@ -489,7 +503,8 @@ function testUICustomizedStrings(){ // Reset locale cache. $this->container->get('string_translation')->reset(); - // Ensure non-customized translation string does appear if searching Non-customized translation. + // Ensure non-customized translation string, + // does appear if searching Non-customized translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', @@ -508,7 +523,8 @@ function testUICustomizedStrings(){ ); $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); - // Ensure unchanged translation string does appear if searching non-customized translation. + // Ensure unchanged translation string does, + // appear if searching non-customized translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', @@ -524,9 +540,11 @@ function testUICustomizedStrings(){ $edit = array( $lid => $this->randomName(100), ); - $this->drupalPostForm('admin/config/regional/translate', $edit, t('Save translations')); + $this->drupalPostForm('admin/config/regional/translate', $edit, + t('Save translations')); - // Ensure changed translation string does appear if searching customized translation. + // Ensure changed translation string, + // does appear if searching customized translation. $search = array( 'string' => $string->getString(), 'langcode' => 'de', diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateBase.php index 2e29d98..77ea4b6 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. @@ -43,14 +43,16 @@ class LocaleUpdateBase extends WebTestBase { * @var array */ public static $modules = array('update', 'locale', 'locale_test'); - - function setUp() { + /** + * Setup The Users Permissions. + */ + 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->timestamp_now = REQUEST_TIME; + $this->timestampold = REQUEST_TIME - 300; + $this->timestampmedium = REQUEST_TIME - 200; + $this->timestampnew = REQUEST_TIME - 100; + $this->timestampnow = REQUEST_TIME; // Enable import of translations. By default this is disabled for automated // tests. @@ -74,7 +76,7 @@ protected function setTranslationsDirectory($path) { /** * Adds a language. * - * @param $langcode + * @param string $langcode * The language code of the language to add. */ protected function addLanguage($langcode) { @@ -91,7 +93,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 +118,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"; } } @@ -176,27 +178,38 @@ protected function setTranslationFiles() { $config->set('translation.default_filename', '%project-%version.%language._po')->save(); // 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_three = array('April' => 'April_3', 'May' => 'Mai_3', 'June' => 'Juni_3'); + $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_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. + * * Setup existing translations in the database and set up the status of * existing translations. */ @@ -246,8 +259,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..cd04f4b 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. @@ -20,7 +20,11 @@ class LocaleUpdateCronTest extends LocaleUpdateBase { * @var array */ public static $modules = array('update', 'locale', 'locale_test'); - + /** + * Get Translations info. + * @return array + * Returns Translations info. + */ public static function getInfo() { return array( 'name' => 'Update translations using cron', @@ -28,10 +32,16 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * Setup The Users Permissions. + */ + public function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface')); + $admin_user = $this->drupalCreateUser(array( + 'administer modules','administer site configuration', + 'administer languages', + 'access administration pages', + 'translate interface')); $this->drupalLogin($admin_user); $this->addLanguage('de'); } @@ -39,7 +49,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..d5abf22 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateInterfaceTest.php @@ -20,7 +20,11 @@ class LocaleUpdateInterfaceTest extends LocaleUpdateBase { * @var array */ public static $modules = array('update', 'locale', 'locale_test_translate'); - + /** + * Get Translations info. + * @return array + * Returns Translations info. + */ public static function getInfo() { return array( 'name' => 'Update translations user interface', @@ -28,10 +32,17 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * Setup The Users Permissions. + */ + public function setUp() { parent::setUp(); - $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface')); + $admin_user = $this->drupalCreateUser(array( + 'administer modules', + 'administer site configuration', + 'administer languages', + 'access administration pages', + 'translate interface')); $this->drupalLogin($admin_user); } @@ -41,7 +52,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..52ecbe0 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php @@ -20,7 +20,11 @@ class LocaleUpdateTest extends LocaleUpdateBase { * @var array */ public static $modules = array('update', 'locale', 'locale_test'); - + /** + * Get Translations info. + * @return array + * Returns Translations info. + */ public static function getInfo() { return array( 'name' => 'Update translations', @@ -28,12 +32,19 @@ public static function getInfo() { 'group' => 'Locale', ); } - - function setUp() { + /** + * Setup The Users Permissions. + */ + public function setUp() { parent::setUp(); module_load_include('compare.inc', 'locale'); module_load_include('fetch.inc', 'locale'); - $admin_user = $this->drupalCreateUser(array('administer modules', 'administer site configuration', 'administer languages', 'access administration pages', 'translate interface')); + $admin_user = $this->drupalCreateUser(array( + 'administer modules', + 'administer site configuration', + 'administer languages', + 'access administration pages', + 'translate interface')); $this->drupalLogin($admin_user); // We use German as test language. This language must match the translation // file that come with the locale_test module (test.de.po) and can therefore @@ -44,7 +55,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 +68,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 +85,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. @@ -126,12 +137,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. @@ -188,12 +199,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. @@ -242,12 +253,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 +289,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 +321,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 +359,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 +403,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 eabedd9..3ddc10f 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(); } } @@ -80,7 +80,7 @@ public function isSource() { /** * Implements Drupal\locale\StringInterface::isTranslation(). - */ + */ public function isTranslation() { return !empty($this->lid) && !empty($this->language) && isset($this->translation); } @@ -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..9da58a9 100644 --- a/core/modules/locale/lib/Drupal/locale/TranslationsStream.php +++ b/core/modules/locale/lib/Drupal/locale/TranslationsStream.php @@ -17,17 +17,19 @@ 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'); } /** - * Implements Drupal\Core\StreamWrapper\StreamWrapperInterface::getExternalUrl(). + * Implements Drupal\Core\StreamWrapper\StreamWrapperInterface. + * + * 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..07eed90 100644 --- a/core/modules/locale/locale.api.php +++ b/core/modules/locale/locale.api.php @@ -29,7 +29,8 @@ * in the module's folder. * @code * interface translation project = example_module - * interface translation server pattern = modules/custom/example_module/%project-%version.%language.po + * interface translation + * server pattern = modules/custom/example_module/%project-%version.%language.po * @endcode * * Streamwrappers can be used in the server pattern definition. The interface @@ -37,22 +38,27 @@ * using the "translations://" streamwrapper. But also other streamwrappers can * be used. * @code - * interface translation server pattern = translations://%project-%version.%language.po + * interface translation + * server pattern = translations://%project-%version.%language.po * @endcode * @code - * interface translation server pattern = public://translations/%project-%version.%language.po + * interface translation + * server pattern = public://translations/%project-%version.%language.po * @endcode * * Multiple custom modules or themes sharing the same po file should have * matching definitions. Such as modules and sub-modules or multiple modules in * the same project/code tree. Both "interface translation project" and - * "interface translation server pattern" definitions of these modules should match. + * "interface translation server pattern" definitions of these modules should + * match. * * Example .info.yml file properties for a custom module with a po file located * on a remote translation server. * @code * interface translation project = example_module - * interface translation server pattern = http://example.com/files/translations/%core/%project/%project-%version.%language.po + * interface translation server pattern = + * http://example.com/files/translations/ + * %core/%project/%project-%version.%language.po * @endcode * * Custom themes, features and distributions can implement these .info.yml file @@ -109,7 +115,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 5085a2b..98675a7 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 Guzzle\Http\Exception\BadResponseException; @@ -33,8 +33,8 @@ * Optional, defaults to TRUE. * @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, $options, &$context) { $failure = $checked = FALSE; $options += array( 'finish_feedback' => TRUE, @@ -86,7 +86,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. @@ -94,13 +94,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( @@ -202,9 +202,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 5f72ad8..f332f18 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; } @@ -121,10 +121,10 @@ function locale_translate_import_form_submit($form, &$form_state) { $language = language_load($form_state['values']['langcode']); if (empty($language)) { $language = new Language(array( - 'id' => $form_state['values']['langcode'] + 'id' => $form_state['values']['langcode'], )); $language = language_save($language); - drupal_set_message(t('The language %language has been created.', array('%language' => t($language->name)))); + drupal_set_message(t('The language %language has been created.', array('%language' => $language->name))); } $options = array( 'langcode' => $form_state['values']['langcode'], @@ -142,7 +142,7 @@ function locale_translate_import_form_submit($form, &$form_state) { } $form_state['redirect_route']['route_name'] = 'locale.translate_page'; - return; + return TRUE; } /** @@ -161,7 +161,7 @@ function locale_translate_import_form_submit($form, &$form_state) { * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. * - * @param $force + * @param bool $force * (optional) Import all available files, even if they were imported before. * * @todo @@ -246,7 +246,7 @@ function locale_translate_get_interface_translation_files($projects = array(), $ /** * Build a locale batch from an array of files. * - * @param $files + * @param array $files * Array of file objects to import. * * @param array $options @@ -262,7 +262,7 @@ function locale_translate_get_interface_translation_files($projects = array(), $ * - 'finish_feedback': Whether or not to give feedback to the user when the * batch is finished. Optional, defaults to TRUE. * - * @return + * @return object * A batch structure or FALSE if $files was empty. */ function locale_translate_batch_build($files, $options) { @@ -275,10 +275,12 @@ function locale_translate_batch_build($files, $options) { $operations = array(); foreach ($files as $file) { // We call locale_translate_batch_import for every batch operation. - $operations[] = array('locale_translate_batch_import', array($file, $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()); @@ -303,8 +305,8 @@ function locale_translate_batch_build($files, $options) { * * @param object $file * A file object of the gettext file to be imported. The file object must - * contain a language parameter (other than Language::LANGCODE_NOT_SPECIFIED). This - * is used as the language of the import. + * contain a language parameter (other than Language::LANGCODE_NOT_SPECIFIED). + * This is used as the language of the import. * * @param array $options * An array with options that can have the following elements: @@ -318,7 +320,7 @@ function locale_translate_batch_build($files, $options) { * - 'message': Alternative message to display during import. Note, this must * be sanitized text. * - * @param $context + * @param array $context * Contains a list of files imported. */ function locale_translate_batch_import($file, $options, &$context) { @@ -399,7 +401,7 @@ function locale_translate_batch_import($file, $options, &$context) { /** * Batch callback: Save data of imported files. * - * @param $context + * @param array $context * Contains a list of imported files. */ function locale_translate_batch_import_save($context) { @@ -505,11 +507,20 @@ function locale_translate_batch_finished($success, $results) { } } drupal_set_message(format_plural(count($results['files']), - 'One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', - '@count translation files imported. %number translations were added, %update translations were updated and %delete translations were removed.', - array('%number' => $additions, '%update' => $updates, '%delete' => $deletes) + 'One translation file imported. %number translations were added, + %update translations were updated and %delete translations were removed.', + '@count translation files imported. %number translations were added, + %update translations were updated and %delete translations were removed.', + array( + '%number' => $additions, + '%update' => $updates, + '%delete' => $deletes) )); - watchdog('locale', 'Translations imported: %number added, %update updated, %delete removed.', array('%number' => $additions, '%update' => $updates, '%delete' => $deletes)); + watchdog('locale', 'Translations imported: %number added, %update updated, %delete removed.', + array( + '%number' => $additions, + '%update' => $updates, + '%delete' => $deletes)); if ($skips) { if (\Drupal::moduleHandler()->moduleExists('dblog')) { @@ -519,7 +530,11 @@ function locale_translate_batch_finished($success, $results) { $message = format_plural($skips, 'One translation string was skipped because of disallowed or malformed HTML. See the log for details.', '@count translation strings were skipped because of disallowed or malformed HTML. See the log for details.'); } drupal_set_message($message, 'warning'); - watchdog('locale', '@count disallowed HTML string(s) in files: @files.', array('@count' => $skips, '@files' => implode(',', $skipped_files)), WATCHDOG_WARNING); + watchdog('locale', '@count disallowed HTML string(s) in files: @files.', + array( + '@count' => $skips, + '@files' => implode(',', $skipped_files)), + WATCHDOG_WARNING); } } } @@ -532,10 +547,10 @@ function locale_translate_batch_finished($success, $results) { /** * Creates a file object and populates the timestamp property. * - * @param $filepath + * @param string $filepath * The filepath of a file to import. * - * @return + * @return object * An object representing the file. */ function locale_translate_file_create($filepath) { @@ -610,7 +625,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. */ @@ -678,16 +693,21 @@ function locale_config_batch_build(array $names, array $langcodes, $options = ar $batch_names[] = $name; $i++; // During installation the caching of configuration objects is disabled - // so it is very expensive to initialize the \Drupal::config() object on each request. + // so it is very expensive to initialize the \Drupal::config() + // object on each request. // We batch a small number of configuration object upgrades together to // improve the overall performance of the process. if ($i % 20 == 0) { - $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes)); + $operations[] = array( + 'locale_config_batch_refresh_name', + array($batch_names, $langcodes)); $batch_names = array(); } } if (!empty($batch_names)) { - $operations[] = array('locale_config_batch_refresh_name', array($batch_names, $langcodes)); + $operations[] = array( + 'locale_config_batch_refresh_name', + array($batch_names, $langcodes)); } $batch = array( 'operations' => $operations, @@ -705,7 +725,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..b87418b 100644 --- a/core/modules/locale/locale.compare.inc +++ b/core/modules/locale/locale.compare.inc @@ -40,7 +40,9 @@ function locale_translation_flush_projects() { * - "project_type": Project type, e.g. 'module', 'theme'. * - "core": Core release version, e.g. 8.x * - "version": Project release version, e.g. 8.x-1.0 - * See http://drupalcode.org/project/drupalorg.git/blob/refs/heads/7.x-3.x:/drupalorg_project/plugins/release_packager/DrupalorgProjectPackageRelease.class.php#l219 + * See http://drupalcode.org/project/drupalorg.git/blob/refs/heads + * /7.x-3.x:/drupalorg_project/plugins/release_packager + * /DrupalorgProjectPackageRelease.class.php#l219 * for how the version strings are created. * - "server_pattern": Translation server po file pattern. * - "status": Project status, 1 = enabled. @@ -114,8 +116,8 @@ function locale_translation_build_projects() { )) ->execute(); - // Invalidate the cache of translatable projects. - locale_translation_clear_cache_projects(); + // Invalidate the cache of translatable projects. + locale_translation_clear_cache_projects(); } return $projects; } @@ -193,7 +195,8 @@ function _locale_translation_prepare_project_list($data, $type) { function locale_translation_default_translation_server() { $pattern = \Drupal::config('locale.settings')->get('translation.default_server_pattern'); // An additional check is required here. During the upgrade process - // \Drupal::config()->get() returns NULL. We use the defined value as fallback. + // \Drupal::config()->get() returns NULL. + // We use the defined value as fallback. $pattern = $pattern ? $pattern : LOCALE_TRANSLATION_DEFAULT_SERVER_PATTERN; return array( @@ -211,8 +214,9 @@ function locale_translation_default_translation_server() { * * @return array * Available sources indexed by project and language. + * + * @todo Return batch or NULL */ -// @todo Return batch or NULL function locale_translation_check_projects($projects = array(), $langcodes = array()) { if (locale_translation_use_remote_source()) { // Retrieve the status of both remote and local translation sources by @@ -282,8 +286,9 @@ 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. @@ -301,7 +306,9 @@ function _locale_translation_batch_status_operations($projects, $langcodes, $opt foreach ($projects as $project) { foreach ($langcodes as $langcode) { // Check status of local and remote translation sources. - $operations[] = array('locale_translation_batch_status_check', array($project, $langcode, $options)); + $operations[] = array( + 'locale_translation_batch_status_check', + array($project, $langcode, $options)); } } diff --git a/core/modules/locale/locale.fetch.inc b/core/modules/locale/locale.fetch.inc index 9568691..1168920 100644 --- a/core/modules/locale/locale.fetch.inc +++ b/core/modules/locale/locale.fetch.inc @@ -2,7 +2,8 @@ /** * @file - * The API for download and import of translations from remote and local sources. + * The API for download and import of translations from remote + * and local sources. */ /** @@ -98,9 +99,13 @@ function _locale_translation_fetch_operations($projects, $langcodes, $options) { foreach ($projects as $project) { foreach ($langcodes as $langcode) { if (locale_translation_use_remote_source()) { - $operations[] = array('locale_translation_batch_fetch_download', array($project, $langcode)); + $operations[] = array( + 'locale_translation_batch_fetch_download', + array($project, $langcode)); } - $operations[] = array('locale_translation_batch_fetch_import', array($project, $langcode, $options)); + $operations[] = array( + 'locale_translation_batch_fetch_import', + array($project, $langcode, $options)); } } diff --git a/core/modules/locale/locale.pages.inc b/core/modules/locale/locale.pages.inc index 7ab9ce0..08ff667 100644 --- a/core/modules/locale/locale.pages.inc +++ b/core/modules/locale/locale.pages.inc @@ -73,7 +73,7 @@ function locale_translation_status_form($form, &$form_state) { $languages_not_found[$langcode] = $langcode; } // Translation update found for this project-language combination. - elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE ) { + elseif ($project_info->type == LOCALE_TRANSLATION_LOCAL || $project_info->type == LOCALE_TRANSLATION_REMOTE) { $local = isset($project_info->files[LOCALE_TRANSLATION_LOCAL]) ? $project_info->files[LOCALE_TRANSLATION_LOCAL] : NULL; $remote = isset($project_info->files[LOCALE_TRANSLATION_REMOTE]) ? $project_info->files[LOCALE_TRANSLATION_REMOTE] : NULL; $recent = _locale_translation_source_compare($local, $remote) == LOCALE_TRANSLATION_SOURCE_COMPARE_LT ? $remote : $local; @@ -90,7 +90,7 @@ function locale_translation_status_form($form, &$form_state) { $languages_not_found = array_diff($languages_not_found, $languages_update); // Build data options for the select table. - foreach($updates as $langcode => $update) { + foreach ($updates as $langcode => $update) { $title = String::checkPlain($languages[$langcode]->name); $locale_translation_update_info = array('#theme' => 'locale_translation_update_info'); foreach (array('updates', 'not_found') as $update_status) { @@ -103,10 +103,12 @@ 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)), + 'status' => array( + 'class' => array('description', 'expand', 'priority-low'), + 'data' => drupal_render($locale_translation_update_info)), ); } // Sort the table data on language name. @@ -138,7 +140,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'))); } @@ -332,7 +334,9 @@ function template_preprocess_locale_translation_update_info(&$variables) { if ($variables['updates']) { foreach ($variables['updates'] as $update) { $modules[] = $update['name']; - $releases[] = t('@module (@date)', array('@module' => $update['name'], '@date' => format_date($update['timestamp'], 'html_date'))); + $releases[] = t('@module (@date)', array( + '@module' => $update['name'], + '@date' => format_date($update['timestamp'], 'html_date'))); } $variables['modules'] = $modules; } @@ -375,7 +379,7 @@ function template_preprocess_locale_translation_update_info(&$variables) { * * Default template: locale-translation-last-check.html.twig. * - * @param $variables + * @param array $variables * An associative array containing: * - last: The timestamp when the site last checked for available updates. * diff --git a/core/modules/locale/locale.translation.inc b/core/modules/locale/locale.translation.inc index fab2a21..b8c9e9c 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. @@ -203,8 +203,8 @@ function locale_translation_source_check_file($source) { * - "files": Array of file objects containing properties of local and remote * translation files. * Other processes can add the following properties: - * - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE and - * LOCALE_TRANSLATION_LOCAL indicate available new translations, + * - "type": Most recent translation source found. LOCALE_TRANSLATION_REMOTE + * and LOCALE_TRANSLATION_LOCAL indicate available new translations, * LOCALE_TRANSLATION_CURRENT indicate that the current translation is them * most recent. "type" sorresponds with a key of the "files" array. * - "timestamp": The creation time of the "type" translation (file). @@ -367,7 +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 e82d0e0..e20af67 100644 --- a/core/modules/locale/tests/Drupal/locale/Tests/LocaleTranslationTest.php +++ b/core/modules/locale/tests/Drupal/locale/Tests/LocaleTranslationTest.php @@ -24,7 +24,11 @@ class LocaleTranslationTest extends UnitTestCase { * @var \PHPUnit_Framework_MockObject_MockObject */ protected $storage; - + /** + * Gets info of locale local tasks. + * @return array + * Returns locale test + */ public static function getInfo() { return array( 'name' => 'Locale translation tests', @@ -43,7 +47,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()); 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..3ec5100 100644 --- a/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php +++ b/core/modules/locale/tests/Drupal/locale/Tests/Menu/LocaleLocalTasksTest.php @@ -16,7 +16,11 @@ * @group Locale */ class LocaleLocalTasksTest extends LocalTaskIntegrationTest { - + /** + * Gets info of locale local tasks. + * @return array + * Returns locale test + */ public static function getInfo() { return array( 'name' => 'Locale local tasks test', @@ -24,7 +28,9 @@ public static function getInfo() { 'group' => 'Locale', ); } - + /** + * Sets the directory path. + */ public function setUp() { $this->directoryList = array( 'locale' => 'core/modules/locale', @@ -39,7 +45,8 @@ public function setUp() { */ public function testLocalePageLocalTasks($route) { $tasks = array( - 0 => array('locale.translate_page', 'locale.translate_import', 'locale.translate_export','locale.settings'), + 0 => array('locale.translate_page', 'locale.translate_import', + 'locale.translate_export','locale.settings'), ); $this->assertLocalTasks($route, $tasks); } diff --git a/core/modules/locale/tests/locale_test.js b/core/modules/locale/tests/locale_test.js index 336d979..e21c60f 100644 --- a/core/modules/locale/tests/locale_test.js +++ b/core/modules/locale/tests/locale_test.js @@ -4,21 +4,15 @@ */ Drupal.t("Standard Call t"); -Drupal - . - t - ( - "Whitespace Call t" - ) -; +Drupal.t("Whitespace Call t"); Drupal.t('Single Quote t'); Drupal.t('Single Quote \'Escaped\' t'); -Drupal.t('Single Quote ' + 'Concat ' + 'strings ' + 't'); +Drupal.t('Single Quote Concat strings t'); Drupal.t("Double Quote t"); Drupal.t("Double Quote \"Escaped\" t"); -Drupal.t("Double Quote " + "Concat " + "strings " + "t"); +Drupal.t("Double Quote Concat strings t"); Drupal.t("Context Unquoted t", {}, {context: "Context string unquoted"}); Drupal.t("Context Single Quoted t", {}, {'context': "Context string single quoted"}); @@ -27,15 +21,7 @@ Drupal.t("Context Double Quoted t", {}, {"context": "Context string double quote Drupal.t("Context !key Args t", {'!key': 'value'}, {context: "Context string"}); Drupal.formatPlural(1, "Standard Call plural", "Standard Call @count plural"); -Drupal - . - formatPlural - ( - 1, - "Whitespace Call plural", - "Whitespace Call @count plural" - ) -; +Drupal.formatPlural(1, "Whitespace Call plural", "Whitespace Call @count plural"); Drupal.formatPlural(1, 'Single Quote plural', 'Single Quote @count plural'); Drupal.formatPlural(1, 'Single Quote \'Escaped\' plural', 'Single Quote \'Escaped\' @count plural');