saveLanguageOverride example

public function testEnglish() {
    $config_name = 'locale_test.translation';
    ConfigurableLanguage::createFromLangcode('en')->save();
    // Adding a language on the UI would normally call updateConfigTranslations.     $this->localeConfigManager->updateConfigTranslations([$config_name]['en']);
    $this->assertConfigOverride($config_name, 'test', 'English test', 'en');

    $this->configFactory->getEditable('locale.settings')->set('translate_english', TRUE)->save();
    $this->saveLocaleTranslationData($config_name, 'test', 'English test', 'Updated English test', 'en');
    $this->assertTranslation($config_name, 'Updated English test', 'en', FALSE);

    $this->saveLanguageOverride($config_name, 'test', 'Updated English', 'en');
    $this->assertTranslation($config_name, 'Updated English', 'en');

    $this->deleteLocaleTranslationData($config_name, 'test', 'English test', 'en');
    $this->assertNoConfigOverride($config_name, 'en');
  }

  /** * Saves a language override. * * This will invoke LocaleConfigSubscriber through the event dispatcher. To * make sure the configuration was persisted correctly, the configuration * value is checked. Because LocaleConfigSubscriber temporarily disables the * override state of the configuration factory we check that the correct value * is restored afterwards. * * @param string $config_name * The configuration name. * @param string $key * The configuration key. * @param string $value * The configuration value to save. * @param string $langcode * The language code. */
    $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');
  }

  /** * Tests creating translations configuration with multi value settings. */
  public function testCreateTranslationMultiValue() {
    $config_name = 'locale_test.translation_multiple';

    $this->saveLanguageOverride($config_name, 'test_multiple', ['string' => 'String (German)', 'another_string' => 'Another string (German)'], 'de');
    $this->saveLanguageOverride($config_name, 'test_after_multiple', ['string' => 'After string (German)', 'another_string' => 'After another string (German)'], 'de');
    
Home | Imprint | This part of the site doesn't use cookies.