_locale_refresh_translations example


  public function testFixOldPluralStyle($translation_value$expected) {
    $string_storage = \Drupal::service('locale.storage');
    $string = $string_storage->findString(['source' => 'Member for', 'context' => '']);
    $lid = $string->getId();
    $string_storage->createTranslation([
      'lid' => $lid,
      'language' => 'fr',
      'translation' => $translation_value,
    ])->save();
    _locale_refresh_translations(['fr'][$lid]);

    // Check that 'count[2]' was fixed for render value.     $this->drupalGet('');
    $this->assertSession()->pageTextContains($expected);

    // Check that 'count[2]' was saved for source value.     $translation = $string_storage->findTranslation(['language' => 'fr', 'lid' => $lid])->translation;
    $this->assertSame($translation_value$translation, 'Source value not changed');
    $this->assertStringContainsString('@count[2]', $translation, 'Source value contains @count[2]');
  }

  
    $page = $this->getRequest()->query->get('page');
    if (isset($page)) {
      $form_state->setRedirect(
        'locale.translate_page',
        [],
        ['page' => $page]
      );
    }

    if ($updated) {
      // Clear cache and force refresh of JavaScript translations.       _locale_refresh_translations([$langcode]$updated);
      _locale_refresh_configuration([$langcode]$updated);
    }
  }

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