Commit 891e57ec authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2609874 by tstoeckler, mikeker, Kristen Pol, tassilogroeper: Boolean...

Issue #2609874 by tstoeckler, mikeker, Kristen Pol, tassilogroeper: Boolean field "On label" and "Off label" are not translatable

(cherry picked from commit 3479333a)
(cherry picked from commit acb8752d)
parent c61815e1
Loading
Loading
Loading
Loading
+2 −2
Changes for core/config/schema/core.data_types.schema.yml: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -605,10 +605,10 @@ field.field_settings.boolean:
  type: mapping
  mapping:
    on_label:
      type: string
      type: label
      label: 'On label'
    off_label:
      type: string
      type: label
      label: 'Off label'

field.value.boolean:
+41 −0
Changes for core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php: 41 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
namespace Drupal\config_translation\Tests;

use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Language\Language;
@@ -733,6 +734,46 @@ public function testFieldConfigTranslation() {
    $this->assertEscaped($translatable_storage_setting);
  }

  /**
   * Tests the translation of a boolean field settings.
   */
  public function testBooleanFieldConfigTranslation() {
    // Add a test boolean field.
    $field_name = strtolower($this->randomMachineName());
    FieldStorageConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'type' => 'boolean',
    ])->save();

    $bundle = strtolower($this->randomMachineName());
    entity_test_create_bundle($bundle);
    $field = FieldConfig::create([
      'field_name' => $field_name,
      'entity_type' => 'entity_test',
      'bundle' => $bundle,
    ]);

    $on_label = 'On label (with <em>HTML</em> & things)';
    $field->setSetting('on_label', $on_label);
    $off_label = 'Off label (with <em>HTML</em> & things)';
    $field->setSetting('off_label', $off_label);
    $field->save();

    $this->drupalLogin($this->translatorUser);

    $this->drupalGet("/entity_test/structure/$bundle/fields/entity_test.$bundle.$field_name/translate");
    $this->clickLink('Add');

    // Checks the text of details summary element that surrounds the translation
    // options.
    $this->assertText(Html::escape(strip_tags($on_label)) . ' Boolean settings');

    // Checks that the correct on and off labels appear on the form.
    $this->assertEscaped($on_label);
    $this->assertEscaped($off_label);
  }

  /**
   * Test translation storage in locale storage.
   */