Motivation
Previously, Numeric entity fields (integer, decimal, and float) had Prefix and Suffix settings, which allowed you to specify singular/plural forms by putting something like "book|books" into either prefix or suffix. The prefix and suffix was automatically displayed in entity editing forms via the numeric field widgets, and optionally displayed in numeric formatters.
However, this method of doing plurals was not workable for translation at all, and was also not correct for single-language sites in languages with plural forms unlike English (such as Russian, which has 3 different forms instead of 2, none of which is really "singular" or "plural").
Furthermore, in Drupal 7 and earlier versions of Drupal 8, if you had a numeric base entity field/property, you could format it in Views using the base Numeric data-field handler in Views, which has the capability of doing (workable) plural formatting, where you would enter the plural forms appropriate to the language. But on #2342045: Standard views base fields need to use same rendering as Field UI fields, for formatting, access checking, and translation consistency this capability was lost in Drupal 8, because entity base fields were changed to use Entity Field Formatters instead of Views generic data handlers.
The actual change
So, on #2545730: Misuse of formatPlural() in Numeric field prefix/suffix, we took out the Prefix/Suffix settings for Numeric entity fields and formatters, and replaced them with a workable plural formatting setting. Configuration changes:
- On Field configuration, under 'settings', the separate 'prefix' and 'suffix' settings are replaced with 'format_plural_string', which supports multiple plural forms (with @count representing the value), separated by \Drupal\Core\StringTranslation\PluralTranslatableMarkup::DELIMITER characters. So if your prefix was $ and suffix was 'USD', your format_plural_string setting would be '$@countUSD', for example.
- On Formatter configuration, which could be embedded in an Entity View Mode or a View, there was a setting called 'prefix_suffix' that was TRUE to display using the prefix/suffix from the field settings, and FALSE to omit this. The new setting is called 'format_plural', and has three choices:
- 'none': No prefix/suffix (equivalent to FALSE on the old setting)
- 'field': Use the prefix/suffix setting from the field (equivalent to TRUE on the old setting)
- 'formatter': Use an overridden prefix/suffix setting on the formatter. This comes from the 'format_plural_string' setting on the formatter, and has the same format as described above for the field setting. - On Widget configuration, which is embedded into Entity Form View configuration, there is a new option format_plural, which can be set to TRUE or FALSE to display or not display the prefix/suffix from the field setting. This option did not exist on Widgets previously.
What module developers need to do
a) If your module defines its own configuration types that include formatters or widgets (like maybe Panels or Display Suites?), you'll need to make a hook_update_N() function to update this configuration for your users. The core update function system_update_8014(), included in the patch in the above issue, shows how to do it for entity view modes, form modes, and views configuration items.
b) If you have exported field, formatter, or widget configuration (or configuration that contains formatters or widgets, like entity form or view modes, views, or your own config types) in your config/install or config/optional directories, you'll need to either update them manually (the issue patch has some examples) or import them into a site, run the updates, and export them again.
What site builders need to do
a) Run the update functions for Drupal Core and any contributed modules that are affected.
b) If you have exported configuration that contains numeric fields, formatters, or widgets, this may also need to be updated.