diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php index d49c68d..74bff5c 100644 --- a/core/modules/locale/src/Form/TranslationStatusForm.php +++ b/core/modules/locale/src/Form/TranslationStatusForm.php @@ -7,10 +7,10 @@ namespace Drupal\locale\Form; -use Drupal\Core\Form\FormBase; +use Drupal\Component\Utility\String; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Form\FormBase; use Drupal\Core\State\StateInterface; -use Drupal\Component\Utility\String; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -93,7 +93,7 @@ public function buildForm(array $form, array &$form_state) { 'class' => array('label'), 'data' => array( '#title' => $title, - '#markup' => $title + '#markup' => $title, ), ), 'status' => array( @@ -104,7 +104,7 @@ public function buildForm(array $form, array &$form_state) { if (!empty($update['not_found'])) { $languages_not_found[$langcode] = $langcode; } - else if (!empty($update['updates'])) { + elseif (!empty($update['updates'])) { $languages_update[$langcode] = $langcode; } } @@ -133,13 +133,17 @@ public function buildForm(array $form, array &$form_state) { ); if (!$languages) { - $empty = $this->t('No translatable languages available. Add a language first.', array('@add_language' => $this->urlGenerator()->generateFromPath('admin/config/regional/language'))); + $empty = $this->t('No translatable languages available. Add a language first.', array( + '@add_language' => $this->url('language.admin_overview'), + )); } elseif ($status) { $empty = $this->t('All translations up to date.'); } - else { - $empty = $this->t('No translation status available. Check manually.', array('@check' => url('admin/reports/translations/check'))); + else { + $empty = $this->t('No translation status available. Check manually.', array( + '@check' => $this->url('locale.check_translation'), + )); } // The projects which require an update. Used by the _submit callback. @@ -205,7 +209,7 @@ protected function prepareUpdateData(array $status) { ); } // 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; diff --git a/core/modules/locale/src/Tests/LocaleUpdateTest.php b/core/modules/locale/src/Tests/LocaleUpdateTest.php index 888d28b..8e754f9 100644 --- a/core/modules/locale/src/Tests/LocaleUpdateTest.php +++ b/core/modules/locale/src/Tests/LocaleUpdateTest.php @@ -21,6 +21,9 @@ class LocaleUpdateTest extends LocaleUpdateBase { */ public static $modules = array('update', 'locale', 'locale_test'); + /** + * {@inheritdoc} + */ public static function getInfo() { return array( 'name' => 'Update translations', @@ -29,11 +32,20 @@ public static function getInfo() { ); } - function setUp() { + /** + * {@inheritdoc} + */ + 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 +56,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 +69,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 +86,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() { // Case when contributed modules are absent. $this->drupalGet('admin/reports/translations'); $this->assertText(t('Missing translations for one project')); @@ -86,7 +98,8 @@ function testUpdateCheckStatus() { // Create local and remote translations files. $this->setTranslationFiles(); - $config->set('translation.default_filename', '%project-%version.%language._po')->save(); + $config->set('translation.default_filename', '%project-%version.%language._po') + ->save(); // Set the test conditions. $edit = array( @@ -130,12 +143,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. @@ -192,12 +205,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. @@ -246,12 +259,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. @@ -282,12 +295,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. @@ -314,7 +327,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); @@ -329,7 +342,11 @@ function testEnableUninstallModule() { // Check if translations have been imported. $this->assertRaw(t('One translation file imported. %number translations were added, %update translations were updated and %delete translations were removed.', - array('%number' => 7, '%update' => 0, '%delete' => 0)), 'One translation file imported.'); + array( + '%number' => 7, + '%update' => 0, + '%delete' => 0, + )), 'One translation file imported.'); $this->assertTranslation('Tuesday', 'Dienstag', 'de'); $edit = array( @@ -352,7 +369,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); @@ -374,7 +391,11 @@ function testEnableLanguage() { // Check if the right number of translations are added. $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)), 'One language added.'); + array( + '%number' => 8, + '%update' => 0, + '%delete' => 0, + )), 'One language added.'); $this->assertTranslation('Extraday', 'extra dag', 'nl'); // Check if the language data is added to the database. @@ -396,7 +417,7 @@ function testEnableLanguage() { /** * Tests automatic translation import when a custom langauge is added. */ - function testEnableCustomLanguage() { + public function testEnableCustomLanguage() { // Make the hidden test modules look like a normal custom module. \Drupal::state()->set('locale.test_system_info_alter', TRUE);