diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index db56e8b..3e5368a 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -196,6 +196,7 @@ public function getRenderer($field_name) { // Instantiate the formatter object from the stored display properties. if (($configuration = $this->getComponent($field_name)) && isset($configuration['type']) && ($definition = $this->getFieldDefinition($field_name))) { + $configuration['settings_langcode'] = $this->langcode; $formatter = $this->pluginManager->getInstance(array( 'field_definition' => $definition, 'view_mode' => $this->originalMode, diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index cffd8ec..8137e1d 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -97,6 +97,9 @@ public function createInstance($plugin_id, array $configuration = array()) { * defaults to the default value specified in the formatter definition. * - third_party_settings: (array) Settings provided by other extensions * through hook_field_formatter_third_party_settings_form(). + * - settings_langcode: (string) The langcode associated to the settings + * passed above. That is typically the langcode of the config entity the + * settings are taken from (an entity_view_display, a view...) * * @return \Drupal\Core\Field\FormatterInterface|null * A formatter object or NULL when plugin is not found. diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index cb71fdd..61cfd0c 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -345,11 +345,6 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, arr $display_options['third_party_settings'] = $plugin_settings[$field_name]['third_party_settings']; } - // Carry the language to the plugin. - if (!empty($display_options)) { - $display_options['settings_langcode'] = $this->entity->get('langcode'); - } - // Get the corresponding plugin object. $plugin = $this->getPlugin($field_definition, $display_options); diff --git a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php index 84331f2..48f74f6 100644 --- a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php +++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php @@ -99,6 +99,9 @@ protected function getPlugin(FieldDefinitionInterface $field_definition, $config $plugin = NULL; if ($configuration && $configuration['type'] != 'hidden') { + // Carry the language to the formatter. + $configuration['settings_langcode'] = $this->entity->langcode; + $plugin = $this->pluginManager->getInstance(array( 'field_definition' => $field_definition, 'view_mode' => $this->entity->getMode(), diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php index 5d6b1bb..eb26f9c 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateFieldFormatterSettingsTest.php @@ -127,20 +127,16 @@ public function testEntityDisplaySettings() { $expected['settings'] = array( 'thousand_separator' => ',', 'prefix_suffix' => TRUE, - 'format_plural' => FALSE, - 'format_plural_string' => '1' . LOCALE_PLURAL_DELIMITER . '@count', ); $component = $display->getComponent('field_test_two'); $this->assertIdentical($expected, $component); $expected['weight'] = 2; $expected['type'] = 'number_decimal'; $expected['settings'] = array( - 'scale' => 2, - 'decimal_separator' => '.', - 'thousand_separator' => ',', - 'prefix_suffix' => TRUE, - 'format_plural' => FALSE, - 'format_plural_string' => '1' . LOCALE_PLURAL_DELIMITER . '@count', + 'scale' => 2, + 'decimal_separator' => '.', + 'thousand_separator' => ',', + 'prefix_suffix' => TRUE, ); $component = $display->getComponent('field_test_three'); $this->assertIdentical($expected, $component); diff --git a/core/modules/views/src/Entity/Render/EntityFieldRenderer.php b/core/modules/views/src/Entity/Render/EntityFieldRenderer.php index 8865a5f..812954d 100644 --- a/core/modules/views/src/Entity/Render/EntityFieldRenderer.php +++ b/core/modules/views/src/Entity/Render/EntityFieldRenderer.php @@ -191,6 +191,8 @@ protected function buildFields(array $values) { if ($values && ($field_ids = $this->getRenderableFieldIds())) { $entity_type_id = $this->getEntityTypeId(); + // @todo could use double-check from dawehner / plach :-) + $settings_langcode = $this->view->storage->language()->id(); // Collect the entities for the relationship, fetch the right translation, // and group by bundle. For each result row, the corresponding entity can @@ -224,6 +226,7 @@ protected function buildFields(array $values) { 'targetEntityType' => $entity_type_id, 'bundle' => $bundle, 'status' => TRUE, + 'langcode' => $settings_langcode, ]); foreach ($display_fields as $field_id => $field) { $display->setComponent($field->definition['field_name'], [ diff --git a/core/modules/views/src/Plugin/views/field/Field.php b/core/modules/views/src/Plugin/views/field/Field.php index 4192719..4937348 100644 --- a/core/modules/views/src/Plugin/views/field/Field.php +++ b/core/modules/views/src/Plugin/views/field/Field.php @@ -478,6 +478,8 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { 'configuration' => array( 'type' => $format, 'settings' => $settings, + // @todo could use double-check from dawehner / plach :-) + 'settings_langcode' => $this->view->storage->language()->id(), 'label' => '', 'weight' => 0, ),