Unverified Commit 4de8670a authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll, justclint,...

Issue #2939356 by Lendude, mediabounds, Manuel Garcia, validoll, justclint, hctom: Fatal error during import translaton of workflows.workflow.editorial.yml config

(cherry picked from commit ea0ab7e5)
parent 87f9f00d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -148,8 +148,8 @@ protected function processTranslatableData($name, array $config, array $translat
        continue;
      }
      if (is_array($item)) {
        $reference_config = isset($reference_config[$key]) ? $reference_config[$key] : [];
        $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config);
        $reference_config_item = isset($reference_config[$key]) ? $reference_config[$key] : [];
        $this->processTranslatableData($name, $config[$key], $item, $langcode, $reference_config_item);
      }
      else {
        $this->saveCustomizedTranslation($name, $item->getUntranslatedString(), $item->getOption('context'), $config[$key], $langcode);
+8 −0
Original line number Diff line number Diff line
test: English test
test_multiple:
  string: 'A string'
  another_string: 'Another string'
  test_after_multiple: false
test_after_multiple:
  string: 'After a string'
  another_string: 'After another string'
+37 −0
Original line number Diff line number Diff line
@@ -19,3 +19,40 @@ locale_test.translation:
      label: 'Test'
      # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest
      translatable: true

locale_test.translation_multiple:
  type: config_object
  label: 'translation settings'
  mapping:
    test:
      type: string
      label: 'Test'
      # See \Drupal\Tests\locale\Kernel\LocaleConfigSubscriberTest
      translatable: true
    test_multiple:
      type: mapping
      label: 'Multiple settings'
      mapping:
        string:
          type: string
          label: 'A string'
          translatable: true
        another_string:
          type: string
          label: 'Another string'
          translatable: true
        test_after_multiple:
          type: boolean
          label: 'Test after multiple'
    test_after_multiple:
      type: mapping
      label: 'Test after multiple settings'
      mapping:
        string:
          type: string
          label: 'A string'
          translatable: true
        another_string:
          type: string
          label: 'Another string'
          translatable: true
+20 −2
Original line number Diff line number Diff line
@@ -99,6 +99,7 @@ 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');
  }

  /**
@@ -111,6 +112,23 @@ public function testCreateTranslation() {
    $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');
    $strings = $this->stringStorage->getTranslations([
      'type' => 'configuration',
      'name' => $config_name,
      'language' => 'de',
      'translated' => TRUE,
    ]);
    $this->assertCount(5, $strings);
  }

  /**
   * Tests importing community translations of shipped configuration.
   */
@@ -245,7 +263,7 @@ protected function setUpTranslation($config_name, $key, $source, $translation, $
   *   The configuration name.
   * @param string $key
   *   The configuration key.
   * @param string $value
   * @param string|array $value
   *   The configuration value to save.
   * @param string $langcode
   *   The language code.
@@ -446,7 +464,7 @@ protected function assertNoTranslation($config_name, $langcode) {
   *
   * @param string $config_name
   *   The configuration name.
   * @param string $translation
   * @param string|array $translation
   *   The translation.
   * @param string $langcode
   *   The language code.