addLanguage example

public function testInterface() {
    // No language added.     // Check status page and Available translation updates page.     $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');
    
$result = $this->connection->executeQuery(
            'SELECT COUNT(*) FROM migration WHERE class LIKE :class',
            ['class' => addcslashes($namespacePrefix, '\\_%') . '%']
        )
            ->fetchOne();

        return (int) $result;
    }

    private function createNonStandardLanguageContext(): Context
    {
        $id = $this->addLanguage($this->iso);

        return new Context(new SystemSource()[], Defaults::CURRENCY, [$id]);
    }

    private function createPluginLifecycleService(PluginService $pluginService): PluginLifecycleService
    {
        return new PluginLifecycleService(
            $this->pluginRepo,
            $this->container->get('event_dispatcher'),
            $this->pluginCollection,
            $this->container->get('service_container'),
            

  protected function setUp(): void {
    parent::setUp();
    $admin_user = $this->drupalCreateUser([
      'administer modules',
      'administer site configuration',
      'administer languages',
      'access administration pages',
      'translate interface',
    ]);
    $this->drupalLogin($admin_user);
    $this->addLanguage('de');
  }

  /** * 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->addCustomFields([
            'code' => CustomFieldTypes::TEXT,
            'de' => CustomFieldTypes::TEXT,
            'system' => CustomFieldTypes::TEXT,
            'systemFloat' => CustomFieldTypes::FLOAT,
            'root' => CustomFieldTypes::TEXT,
            'child' => CustomFieldTypes::TEXT,
        ]);

        $rootLanguageId = Uuid::randomHex();
        $childLanguageId = Uuid::randomHex();
        $this->addLanguage($rootLanguageId, null);
        $this->addLanguage($childLanguageId$rootLanguageId);

        $repo = $this->getTestRepository();
        $context = Context::createDefaultContext();

        $id = Uuid::randomHex();

        $entity = [
            'id' => $id,
            'name' => 'translated',
            'translations' => [
                
$admin_user = $this->drupalCreateUser([
      '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     // not be chosen randomly.     $this->addLanguage('de');
  }

  /** * Checks if local or remote translation sources are detected. * * The translation status process by default checks the status of the * installed projects. For testing purpose a predefined set of modules with * fixed file names and release versions is used. This custom project * definition is applied using a hook_locale_translation_projects_alter * implementation in the locale_test module. * * This test generates a set of local and remote translation files in their * respective local and remote translation directory. The test checks whether * the most recent files are selected in the different check scenarios: check * for local files only, check for both local and remote files. */
Home | Imprint | This part of the site doesn't use cookies.