Problem/Motivation

In the "Manage display" tab on a node you can set a format for field of type "Number (decimal). When you choose "Default" there are some settings for thousand marker and decimal marker, but these are not language specific. I would like them to be translatable or at least have an option like "Default for display language" and have them set automatically according to the locale of each language.

In some countries, 1,000 means one (1), whereas in other countries, the comma is used as a thousand separator, so it means one thousand (1000).

We can translate Label, Prefix, and Suffix for a field, but wouldn't it be great to also be able to set the Thousand marker and Decimal marker by language?

Steps to reproduce

Proposed resolution

  1. Localization on Regional settings page

    Add Localization options for each installed language on the Regional settings page (/admin/config/regional/settings), inside the Locale fieldset. The user can set custom separators for each installed language (da, en, fr, etc.).

    Localization example

    Detaching language from localization givers more flexibility to the site owner. He may want to use a different set of number separators than what we would expect for his region.

    Consider adding those settings to the user profile page as well, so a user is able to override the global localization settings.

  2. Using Localization for each installed language in field displays

    Add a new option under the "Thousand marker" and "Decimal marker" settings from the "Manage display" page (/admin/structure/types/manage/article/display).

    It could be an option the user can select, where either a global character is used, or a language specific. The current select options could be updated to this:

    Thousand marker

    • - None -
    • Decimal point
    • Comma
    • Space
    • Thin space
    • Default for display language <<< Add this option

    Decimal marker

    • Decimal point
    • Comma
    • Default for display language <<< Add this option

Remaining tasks

For the number formats https://www.drupal.org/project/advanced_number_format might be a good starting point if we want to start in contrib, and eventually get it into Drupal core.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Comments

jeanfredrik created an issue. See original summary.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

avpaderno’s picture

Issue tags: -decimal number field formatter, -language specific number formats +decimal numbers, +localization
avpaderno’s picture

Issue tags: -decimal numbers +Decimal numbers

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

ressa’s picture

Issue summary: View changes

This is a great idea. I created a duplicate issue the other day, which I will close. (#3525024: Allow translating Thousand marker and Decimal marker under Display)

ressa’s picture

Issue summary: View changes
ressa’s picture

Issue summary: View changes
ressa’s picture

Title: Allow localizing of formatting on decimal fields » Allow localizing of formatting on Thousand marker and Decimal marker
ressa’s picture

Title: Allow localizing of formatting on Thousand marker and Decimal marker » Allow localizing installed languages on Regional settings page to set Thousand and Decimal marker
Component: field system » locale.module
Issue summary: View changes
anybody’s picture

For the number formats https://www.drupal.org/project/advanced_number_format might be a good starting point if we want to start in contrib.

ressa’s picture

Issue summary: View changes

Thanks for the suggestion @anybody! I have added it in the Issue Summary to highlight your great initiative.

Though that also seems to include number manipulation (such as rounding), which could add complexity, whereas the scope here is purely presentation, and visualizing numbers by defining Thousand and Decimal separators ... But if the added features are not blockers, it's no problem. Also, I do see the benefit of thinking more holistically about it, though that may also cause an issue to balloon, and get bikeshedded. It's a balance :)

xmacinfo’s picture

Yes, indeed, we only need to touch presentation.

In the database (or result of calculation, eg. sales tax) me may have a value of “1.131416”. When presenting that value, the display would be transformed to:

Decimals and thousands separators:

Typical English localization:
1.131,416

Typical French localization:
1,131 416

Typical English localization:
10 123.13

Typical French localization:
10 123,13

Currency sign formatter:

Typical English localization:
$10 123.13

Typical French localization:
10 123,13 $

etc.

For measurements units, the database must also store the default measurement unit, most probably loaded from a config. So, if the config for the site is set to imperial units, we can still use a single value in the database and load the unit config at display time.

Example of a Canadian number with a measurement unit coming from default:

Typical Canadian English localization:
1.5L

Typical French localization:
1,5 L

Not sure if core should offers tool to convert unit of measures or use a vendor.

But the UI, if enabled, should let users convert unit of measures easily.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.