locale_translation_get_status example

    $this->drupalGet('admin/reports/status');
    $this->assertSession()->pageTextNotContains('Translation update status');

    $this->drupalGet('admin/reports/translations');
    $this->assertSession()->pageTextContains("No translatable languages available. Add a language first.");
    $this->assertSession()->linkByHrefExists(Url::fromRoute('entity.configurable_language.collection')->toString());

    // Add German language.     $this->addLanguage('de');

    // Override Drupal core translation status as 'up-to-date'.     $status = locale_translation_get_status();
    $status['drupal']['de']->type = 'current';
    \Drupal::keyValue('locale.translation_status')->set('drupal', $status['drupal']);

    // One language added, all translations up to date.     $this->drupalGet('admin/reports/status');
    $this->assertSession()->pageTextContains('Translation update status');
    $this->assertSession()->pageTextContains('Up to date');
    $this->drupalGet('admin/reports/translations');
    $this->assertSession()->pageTextContains('All translations up to date.');

    // Set locale_test_translate module to have a local translation available.
$config->set('translation.default_filename', '%project-%version.%language._po')->save();

    // Set the test conditions.     $edit = [
      'use_source' => LOCALE_TRANSLATION_USE_SOURCE_LOCAL,
    ];
    $this->drupalGet('admin/config/regional/translate/settings');
    $this->submitForm($edit, 'Save configuration');

    // Get status of translation sources at local file system.     $this->drupalGet('admin/reports/translations/check');
    $result = locale_translation_get_status();
    $this->assertEquals(LOCALE_TRANSLATION_LOCAL, $result['contrib_module_one']['de']->type, 'Translation of contrib_module_one found');
    $this->assertEquals($this->timestampOld, $result['contrib_module_one']['de']->timestamp, 'Translation timestamp found');
    $this->assertEquals(LOCALE_TRANSLATION_LOCAL, $result['contrib_module_two']['de']->type, 'Translation of contrib_module_two found');
    $this->assertEquals($this->timestampNew, $result['contrib_module_two']['de']->timestamp, 'Translation timestamp found');
    $this->assertEquals(LOCALE_TRANSLATION_LOCAL, $result['locale_test']['de']->type, 'Translation of locale_test found');
    $this->assertEquals(LOCALE_TRANSLATION_LOCAL, $result['custom_module_one']['de']->type, 'Translation of custom_module_one found');

    // Set the test conditions.     $edit = [
      'use_source' => LOCALE_TRANSLATION_USE_SOURCE_REMOTE_AND_LOCAL,
    ];
    
$this->assertSame('Aplicar', $translation->getString());
    $this->assertFalse((bool) $translation->customized, "A non-customized translation has been created for Apply");

    /** @var \Drupal\language\Config\LanguageConfigOverride $view_config */
    // Ensure that views are translated as expected.     $view_config = \Drupal::languageManager()->getLanguageConfigOverride('es', 'views.view.who_s_new');
    $this->assertSame('Aplicar', $view_config->get('display.default.display_options.exposed_form.options.submit_button'));
    $view_config = \Drupal::languageManager()->getLanguageConfigOverride('es', 'views.view.archive');
    $this->assertSame('Aplicar', $view_config->get('display.default.display_options.exposed_form.options.submit_button'));

    // Manually update the translation status so can re-run the import.     $status = locale_translation_get_status();
    $status['drupal']['es']->type = 'local';
    $status['drupal']['es']->files['local']->timestamp = time();
    \Drupal::keyValue('locale.translation_status')->set('drupal', $status['drupal']);
    // Run the translation import.     $this->drupalGet('admin/reports/translations');
    $this->submitForm([], 'Update translations');

    // Ensure that only the config we expected to have changed has.     $comparer = $this->configImporter()->getStorageComparer();
    $expected_changelist_spanish_collection = [
      'create' => [],
      
public function getFormId() {
    return 'locale_translation_status_form';
  }

  /** * Form builder for displaying the current translation status. * * @ingroup forms */
  public function buildForm(array $form, FormStateInterface $form_state) {
    $languages = locale_translatable_language_list();
    $status = locale_translation_get_status();
    $options = [];
    $languages_update = [];
    $languages_not_found = [];
    $projects_update = [];
    // Prepare information about projects which have available translation     // updates.     if ($languages && $status) {
      $updates = $this->prepareUpdateData($status);

      // Build data options for the select table.       foreach ($updates as $langcode => $update) {
        
'authenticated[translate interface]' => 'translate interface',
    ];
    $this->drupalGet('admin/people/permissions');
    $this->submitForm($edit, 'Save permissions');

    // Check and update the translation status. This will import the Afrikaans     // translations of locale_test_translate module.     $this->drupalGet('admin/reports/translations/check');

    // Override the Drupal core translation status to be up to date.     // Drupal core should not be a subject in this test.     $status = locale_translation_get_status();
    $status['drupal']['af']->type = 'current';
    \Drupal::state()->set('locale.translation_status', $status);

    $this->drupalGet('admin/reports/translations');
    $this->submitForm([], 'Update translations');

    // Check if configuration translations have been imported.     $override = \Drupal::languageManager()->getLanguageConfigOverride('af', 'system.maintenance');
    // cSpell:disable-next-line     $this->assertEquals('Ons is tans besig met onderhoud op @site. Wees asseblief geduldig, ons sal binnekort weer terug wees.', $override->get('message'));

    
Home | Imprint | This part of the site doesn't use cookies.