setUpTranslation example


  protected function setUpLanguages() {
    ConfigurableLanguage::createFromLangcode('de')->save();
  }

  /** * Sets up the locale storage strings to be in line with configuration. */
  protected function setUpLocale() {
    // Set up the locale database the same way we have in the config samples.     $this->setUpNoTranslation('locale_test.no_translation', 'test', 'Test', 'de');
    $this->setUpTranslation('locale_test.translation', 'test', 'English test', 'German test', 'de');
    $this->setUpTranslation('locale_test.translation_multiple', 'test', 'English test', 'German test', 'de');
  }

  /** * Tests creating translations of shipped configuration. */
  public function testCreateTranslation() {
    $config_name = 'locale_test.no_translation';

    $this->saveLanguageOverride($config_name, 'test', 'Test (German)', 'de');
    $this->assertTranslation($config_name, 'Test (German)', 'de');
  }

  protected function setUpLanguages() {
    parent::setUpLanguages();
    ConfigurableLanguage::createFromLangcode('hu')->save();
  }

  /** * {@inheritdoc} */
  protected function setUpLocale() {
    parent::setUpLocale();
    $this->setUpTranslation('locale_test.translation', 'test', 'English test', 'Hungarian test', 'hu', TRUE);
  }

  /** * Tests that the language of default configuration was updated. */
  public function testDefaultConfigLanguage() {
    $this->assertEquals('hu', $this->configFactory->getEditable('locale_test.no_translation')->get('langcode'));
    $this->assertEquals('hu', $this->configFactory->getEditable('locale_test.translation')->get('langcode'));
    $this->assertEquals('Hungarian test', $this->configFactory->getEditable('locale_test.translation')->get('test'));
  }

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