diff --git a/core/config/schema/core.entity.schema.yml b/core/config/schema/core.entity.schema.yml index 43b339f..07e4714 100644 --- a/core/config/schema/core.entity.schema.yml +++ b/core/config/schema/core.entity.schema.yml @@ -279,7 +279,7 @@ field_formatter_settings_numeric_base: label: 'Display prefix and suffix' format_plural: type: boolean - label: 'Format plural' + label: 'Use plural formatting' format_plural_string: type: label label: 'Singular and one or more plurals' diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 3e5368a..afb9a88 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -196,6 +196,8 @@ 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))) { + // Record the language that the configuration was translated into, which + // is needed for plural formatting (for example). $configuration['settings_langcode'] = $this->langcode; $formatter = $this->pluginManager->getInstance(array( 'field_definition' => $definition, diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index c6835bb..41f8701 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -63,7 +63,7 @@ * @param array $third_party_settings * Any third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. */ public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, $settings_langcode) { parent::__construct(array(), $plugin_id, $plugin_definition); diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index 882a2ac..d100add 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -97,9 +97,10 @@ 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...) + * - settings_langcode: (string) The language code associated to the + * settings passed above. That is typically the language code of the + * configuration 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/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index b15a734..40d6686 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -53,9 +53,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase implem * @param array $third_party_settings * Any third party settings settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager - * The entity manager. + * The language code associated with the settings passed above. * @param LoggerChannelFactoryInterface $logger_factory * The logger factory. */ diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php index 69e30e0..7c314dd 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php @@ -53,7 +53,7 @@ class LanguageFormatter extends StringFormatter { * @param array $third_party_settings * Any third party settings settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php index f97d0a7..1a167d5 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/NumericFormatterBase.php @@ -60,7 +60,7 @@ public function settingsForm(array $form, FormStateInterface $form_state) { $elements['format_plural'] = array( '#type' => 'checkbox', - '#title' => $this->t('Format plural'), + '#title' => $this->t('Use plural formatting'), '#description' => $this->t('If checked, special handling will be used for plurality.'), '#default_value' => $this->getSetting('format_plural'), ); @@ -92,23 +92,25 @@ public function settingsForm(array $form, FormStateInterface $form_state) { } /** - * Form API callback. Sets the value for format_plural_string. + * After-build callback: Sets the value for the format_plural_string property. * - * This method is assigned as a #after_build in settingsForm() method. + * This method is assigned as an #after_build function in + * \namespace\class::settingsForm(). + * + * The user interface for setting up singular/plural forms is an array of text + * fields, for usability, but for translation purposes, the values have to be + * stored as a single string in the field settings. This function implodes the + * values. * * @param array $element - * Textfield elements where the plural format should be set. + * Textfield element where the plural format should be set. * @param \Drupal\Core\Form\FormStateInterface $form_state * The current state of the form. * * @return array - * Textfield elements with plural string set. + * Textfield element with plural string set. */ public static function formatPluralValuesAfterBuild($element, FormStateInterface $form_state) { - // The 'format_plural_values' element is a list of textfields, but we want - // to store a 'format_plural_string' string as the setting value, so add - // that to $form_state. It's not necessary to remove 'format_plural_values' - // from $form_state, because only defined settings get retained anyway. if ($form_state->isProcessingInput()) { $keys = $element['#parents']; $array_value = $form_state->getValue($keys); diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php index 4974699..2efa26c 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php @@ -53,7 +53,7 @@ class StringFormatter extends FormatterBase implements ContainerFactoryPluginInt * @param array $third_party_settings * Any third party settings settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php index f1d0abd..3588bba 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampAgoFormatter.php @@ -64,7 +64,7 @@ class TimestampAgoFormatter extends FormatterBase implements ContainerFactoryPlu * @param array $third_party_settings * Any third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. * @param \Symfony\Component\HttpFoundation\Request $request diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php index fa12e66..f949699 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/TimestampFormatter.php @@ -63,7 +63,7 @@ class TimestampFormatter extends FormatterBase implements ContainerFactoryPlugin * @param array $third_party_settings * Third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. * @param \Drupal\Core\Entity\EntityStorageInterface $date_format_storage diff --git a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index c949312..7e87543 100644 --- a/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/src/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -120,7 +120,7 @@ public static function create(ContainerInterface $container, array $configuratio * @param array $third_party_settings * Third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php index 848eede..4000af5 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeFormatterBase.php @@ -54,7 +54,7 @@ * @param array $third_party_settings * Third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. * @param \Drupal\Core\Entity\EntityStorageInterface $date_format_storage diff --git a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php index 19f34a9..14cdffc 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php +++ b/core/modules/datetime/src/Plugin/Field/FieldFormatter/DateTimeTimeAgoFormatter.php @@ -63,7 +63,7 @@ class DateTimeTimeAgoFormatter extends FormatterBase implements ContainerFactory * @param array $third_party_settings * Third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Datetime\DateFormatter $date_formatter * The date formatter service. * @param \Symfony\Component\HttpFoundation\Request $request diff --git a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php index c840301..d5fa94b 100644 --- a/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php +++ b/core/modules/image/src/Plugin/Field/FieldFormatter/ImageFormatter.php @@ -71,7 +71,7 @@ class ImageFormatter extends ImageFormatterBase implements ContainerFactoryPlugi * @param array $third_party_settings * Any third party settings settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Session\AccountInterface $current_user * The current user. * @param \Drupal\Core\Utility\LinkGeneratorInterface $link_generator diff --git a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php index 2bd99c0..5cf1565 100644 --- a/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/src/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -76,7 +76,7 @@ public static function create(ContainerInterface $container, array $configuratio * @param array $third_party_settings * Third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Path\PathValidatorInterface $path_validator * The path validator service. */ diff --git a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php index 3bd9e06..6e8bf69 100644 --- a/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php +++ b/core/modules/responsive_image/src/Plugin/Field/FieldFormatter/ResponsiveImageFormatter.php @@ -60,7 +60,7 @@ class ResponsiveImageFormatter extends ImageFormatterBase implements ContainerFa * @param array $third_party_settings * Any third party settings. * @param string $settings_langcode - * The langcode associated to the settings passed above. + * The language code associated with the settings passed above. * @param \Drupal\Core\Entity\EntityStorageInterface $responsive_image_style_storage * The responsive image style storage. * @param \Drupal\Core\Entity\EntityStorageInterface $image_style_storage