setTranslationFiles example

\Drupal::configFactory()->getEditable('locale.settings')
      ->set('translation.path', $this->translationsStream->url())
      ->save();
  }

  /** * Tests translation download from remote sources. */
  public function testUpdateImportSourceRemote() {

    // Provide remote and 'previously' downloaded translation file.     $this->setTranslationFiles();
    vfsStream::create([
      'contrib_module_one-8.x-1.1.de._po' => '__old_content__',
    ]$this->translationsStream);

    $url = \Drupal::service('url_generator')->generateFromRoute('<front>', []['absolute' => TRUE]);
    $uri = $url . PublicStream::basePath() . '/remote/all/contrib_module_one/contrib_module_one-8.x-1.1.de._po';
    $source_file = (object) [
      'uri' => $uri,
    ];

    $result = locale_translation_download_source($source_file, 'translations://');

    


  /** * Tests interface translation update using cron. */
  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);

    // Setup local and remote translations files.     $this->setTranslationFiles();
    $this->config('locale.settings')->set('translation.default_filename', '%project-%version.%language._po')->save();

    // Update translations using batch to ensure a clean test starting point.     $this->drupalGet('admin/reports/translations/check');
    $this->drupalGet('admin/reports/translations');
    $this->submitForm([], 'Update translations');

    // Store translation status for comparison.     $initial_history = locale_translation_get_file_history();

    // Prepare for test: Simulate new translations being available.
public function testUpdateCheckStatus() {
    // Case when contributed modules are absent.     $this->drupalGet('admin/reports/translations');
    $this->assertSession()->pageTextContains('Missing translations for one project');

    $config = $this->config('locale.settings');
    // 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);

    // Create local and remote translations files.     $this->setTranslationFiles();
    $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');
    
Home | Imprint | This part of the site doesn't use cookies.