locale_translation_build_projects example


  protected function prepareUpdateData(array $status) {
    $updates = [];

    // @todo Calling locale_translation_build_projects() is an expensive way to     // get a module name. In follow-up issue     // https://www.drupal.org/node/1842362 the project name will be stored to     // display use, like here.     $this->moduleHandler->loadInclude('locale', 'compare.inc');
    $project_data = locale_translation_build_projects();

    foreach ($status as $project) {
      foreach ($project as $langcode => $project_info) {
        // No translation file found for this project-language combination.         if (empty($project_info->type)) {
          $updates[$langcode]['not_found'][] = [
            'name' => $project_info->name == 'drupal' ? $this->t('Drupal core') : $project_data[$project_info->name]->info['name'],
            'version' => $project_info->version,
            'info' => $this->createInfoString($project_info),
          ];
        }
        
'administer modules',
      'administer languages',
      'access administration pages',
      'translate interface',
    ]);
    $this->drupalLogin($admin_user);
    $this->drupalGet('admin/config/regional/language/add');
    $this->submitForm(['predefined_langcode' => 'hu'], 'Add language');
  }

  public function testLocaleUpdateDevelopmentRelease() {
    $projects = locale_translation_build_projects();
    $this->assertEquals('8.0.x', $projects['drupal']->info['version'], 'The branch of the core dev release.');
    $this->assertEquals('12.x-10.x', $projects['contrib']->info['version'], 'The branch of the contrib module dev release.');
  }

}
public function testBuildProjects() {
    $this->container->get('module_handler')->loadInclude('locale', 'compare.inc');
    /** @var \Drupal\Core\Extension\ExtensionList $module_list */
    $module_list = \Drupal::service('extension.list.module');

    // Make the test modules look like a normal custom module. I.e. make the     // modules not hidden. locale_test_system_info_alter() modifies the project     // info of the locale_test and locale_test_translate modules.     \Drupal::state()->set('locale.test_system_info_alter', TRUE);

    // Confirm the project name and core value before the module is altered.     $projects = locale_translation_build_projects();
    $this->assertSame('locale_test', $projects['locale_test']->name);
    $this->assertSame('all', $projects['locale_test']->core);

    $projects['locale_test']->langcode = 'de';
    $this->assertSame('/all/locale_test/locale_test-1.2.de.po', locale_translation_build_server_pattern($projects['locale_test'], '/%core/%project/%project-%version.%language.po'));

    // Alter both the name and core value of the project.     \Drupal::state()->set('locale.test_system_info_alter_name_core', TRUE);
    drupal_static_reset('locale_translation_project_list');
    $module_list->reset();

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