Allow localizing of formatting on decimal fields

Created on 28 June 2016, about 9 years ago
Updated 23 May 2025, 4 months ago

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

Perhaps move the "Thousand marker" and "Decimal marker" settings from the "Manage display" page (/admin/structure/types/manage/municipality/display) to the field settings page? (/admin/structure/types/manage/article/fields/node.article.field_number), and live together with similar setting options, such as prefix suffix ?

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

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

field system

Created by

πŸ‡ΈπŸ‡ͺSweden jeanfredrik

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

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

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen
  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    Updating Issue Summary based on great discussion in ✨ META: Provide locale (regional) formats framework for automated translation of non textual data Active .

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    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.

  • πŸ‡©πŸ‡°Denmark ressa Copenhagen

    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 :)

  • πŸ‡¨πŸ‡¦Canada xmacinfo Canada

    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.

Production build 0.71.5 2024