Opened 11 months ago
Last modified 2 months ago
#35095 assigned Cleanup/optimization
Monetary values in Switzerland discrepancy
Reported by: | Andrea Angelini | Owned by: | Aditya Chaudhary |
---|---|---|---|
Component: | Internationalization | Version: | 5.0 |
Severity: | Normal | Keywords: | |
Cc: | Claude Paroz, Silvan Spross | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | yes | UI/UX: | no |
Description
At this link (https://docs.djangoproject.com/en/5.0/topics/i18n/formatting/#switzerland-german) the documentation says:
Switzerland (German) [...] For monetary values, a comma is used as the thousand separator and a decimal point for the decimal separator.
At this link (https://github.com/django/django/blob/main/django/conf/locale/de_CH/formats.py) the comment says:
For monetary numbers, the DECIMAL_SEPARATOR is a . (decimal point) and the THOUSAND_SEPARATOR is a ' (single quote).
Unfortunately I'm not familiar with the de_CH
locale, therefore I can't say which one is correct.
Change History (25)
comment:1 by , 11 months ago
Cc: | added |
---|---|
Component: | Documentation → Internationalization |
Resolution: | → invalid |
Status: | new → closed |
follow-up: 3 comment:2 by , 11 months ago
Resolution: | invalid |
---|---|
Status: | closed → new |
I agree with you that for non-monetary numbers, the documentation and the code match.
What I pointed out is that, for monetary numbers, the documentation says "For monetary values, a comma is used as the thousand separator", whilst the comment in the code says "For monetary numbers, [...] the THOUSAND_SEPARATOR is a ' (single quote)".
follow-up: 5 comment:3 by , 11 months ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
What I pointed out is that, for monetary numbers, the documentation says "a comma is used as the thousand separator", whilst the comment in format says "the THOUSAND_SEPARATOR is a ' (single quote)".
OK, but it's not something that Django uses, so it's just a real minor typo in docs/comments.
For the future, that kind of cleanups doesn't require a ticket, feel-free to check sources and submit PR.
comment:4 by , 11 months ago
Cc: | added |
---|
comment:5 by , 11 months ago
Replying to Mariusz Felisiak:
What I pointed out is that, for monetary numbers, the documentation says "a comma is used as the thousand separator", whilst the comment in format says "the THOUSAND_SEPARATOR is a ' (single quote)".
OK, but it's not something that Django uses, so it's just a real minor typo in docs/comments.
For the future, that kind of cleanups doesn't require a ticket, feel-free to check sources and submit PR.
Hii! I am very new to open source, and I want to fix this typo, please help me out. So where exactly is the typo? In the documentation or the comments?
comment:6 by , 11 months ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:7 by , 11 months ago
Has patch: | set |
---|
pull request: https://github.com/NeilPen2005/django/pull/1
comment:8 by , 11 months ago
Has patch: | unset |
---|
Patch should be sent via GitHub PR targeted to the main
Django branch. Do you have any Swiss friend who can confirm this change?
follow-up: 12 comment:9 by , 11 months ago
In the comment is a reference to a seems to be official document: https://www.bk.admin.ch/bk/de/home/dokumentation/sprachen/hilfsmittel-textredaktion/schreibweisungen.html
Ziffern werden in Dreiergruppen zusammengefasst. 123 456 789 Besteht eine Zahl aus vier Ziffern, so wird die erste nicht abgesetzt, sondern eine Vierergruppe gebildet. 1234 Zahlen, die aus mehr als vier Ziffern bestehen, werden von der Endziffer aus in Dreiergruppen zerlegt. 22 333 / 222 333 / 1 222 333
Digits are grouped into groups of three. 123 456 789 If a number consists of four digits, the first is not separated, but a group of four is formed. 1234 Numbers that consist of more than four digits are broken down into groups of three starting from the final digit. 22 333 / 222 333 / 1 222 333
And
Die früher gebräuchliche Schreibung mit Apostroph sollte nicht mehr angewendet werden, weil sie für die Drucklegung wieder rückgängig gemacht werden muss. Nicht korrekt ist die Gliederung mit Punkten oder Kommas.
The previously used spelling with an apostrophe (aka single-quote) should no longer be used because it has to be reversed for printing. The structure with periods or commas is not correct.
So the THOUSAND_SEPARATOR seems to be the non-breaking-space (as implemented) and not single-quote
or coma
(as in the PR), regardless of plain numbers or monetary value.
comment:10 by , 11 months ago
Has patch: | set |
---|---|
Patch needs improvement: | set |
comment:11 by , 11 months ago
I stumbled upon that discrepancy just by chance. I have no Swiss friend that can confirm it. Checking the sources with Google seems to favor the single quote.
What I also found is that Angular CurrencyPipe
seems to use the single quote as thousand separator.
https://github.com/angular/angular/issues/46038#issuecomment-1335706796
follow-ups: 13 17 comment:12 by , 11 months ago
Replying to Alexander Lazarević:
So the THOUSAND_SEPARATOR seems to be the non-breaking-space (as implemented) and not
single-quote
orcoma
(as in the PR), regardless of plain numbers or monetary value.
This PR is not about values used by Django, it's about comments and docs. Please check previous comments.
Django uses separators for non-monetary numbers i.e.
DECIMAL_SEPARATOR = "," THOUSAND_SEPARATOR = "\xa0" # non-breaking space
However, both docs and comments mention that for monetary values format is different. The question is, should we change a comment to the:
"For monetary numbers, the DECIMAL_SEPARATOR is a . (decimal point) and the THOUSAND_SEPARATOR is a , (comma)."
or should we change docs to the:
"For monetary values, a single quote is used as the thousand separator and a decimal point for the decimal separator."
comment:13 by , 11 months ago
It seems that the official documentation pointed out by Alexander says that a non-breaking space as thousand separator should be used for *any* number, monetary values included.
On the other side, the decimal separator is a comma for plain numbers, and a dot for monetary values (as correctly commented and implemented by Django).
comment:14 by , 11 months ago
If it's outdated, we can remove notes about THOUSAND_SEPARATOR
for monetary values from both docs and comments.
Claude, What do you think?
comment:15 by , 11 months ago
Has patch: | unset |
---|---|
Patch needs improvement: | unset |
follow-up: 18 comment:16 by , 11 months ago
Django has no way to differentiate formatting between monetary values and other values. This formatting difference is a Swiss peculiarity, AFAIK. So the current setting values are valid for most number, except monetary values. I admit the comment is not very clear about that and could be improved. By the way the fr_CH
formats file could have the same comment, as the situation is the same.
In my apps, I generally add an |unlocalize
filter each time I have to display a monetary value, so the .
is used to format those numbers. This solution is fine for Swiss-only apps, but fails in multi-country apps. We could imagine implementing a special monetary
filter/tag, but it looks overkill if it's just for one country, considering that Swiss people will also understand when a comma is used for monetary values, it's just not the official way of printing them.
comment:17 by , 11 months ago
Replying to Mariusz Felisiak:
This PR is not about values used by Django, it's about comments and docs. Please check previous comments.
That was my understanding from the beginning and I commented accordingly in the PR. Sorry for not being clear about that here.
However, both docs and comments mention that for monetary values format is different. The question is, should we change a comment to the:
"For monetary numbers, the DECIMAL_SEPARATOR is a . (decimal point) and the THOUSAND_SEPARATOR is a , (comma)."
or should we change docs to the:
"For monetary values, a single quote is used as the thousand separator and a decimal point for the decimal separator."
Here I disagree, because from what I read in the referred official document there is no special thousand separator for monetary values. So my suggestion in the PR was to change the comment (and docs) to:
"For monetary numbers, the DECIMAL_SEPARATOR is a . (decimal point)."
But maybe others can point me to the definition of a special thousand separator for monetary values in the referred document? I wasn't able to find one skimming the doc.
comment:18 by , 11 months ago
Replying to Claude Paroz:
This formatting difference is a Swiss peculiarity, AFAIK.
And as far as I can tell there is also difference when formatting monetary values given in Franken or Rappen. So it's Fr. 15.40 but 0,13 Rp.
comment:19 by , 11 months ago
Well, on the other hand when I look at latest /usr/share/i18n/locales/de_CH on my system, it seems to be outdated as well and no help on the question:
... date "2007-09-23" ... LC_MONETARY int_curr_symbol "CHF " currency_symbol "CHF" mon_decimal_point "." mon_thousands_sep "<U2019>" mon_grouping 3;3 positive_sign "" negative_sign "-" int_frac_digits 2 frac_digits 2 p_cs_precedes 1 p_sep_by_space 1 n_cs_precedes 1 n_sep_by_space 1 p_sign_posn 4 n_sign_posn 4 END LC_MONETARY LC_NUMERIC decimal_point "." thousands_sep "<U2019>" grouping 3;3 END LC_NUMERIC
With ' (U+2019 RIGHT SINGLE QUOTATION MARK)
comment:20 by , 11 months ago
So finally I vote to change the comment from:
# these are the separators for non-monetary numbers. For monetary numbers, # the DECIMAL_SEPARATOR is a . (decimal point) and the THOUSAND_SEPARATOR is a # , (comma).
to:
# These are the separators for non-monetary numbers. # The decimal separator for monetary numbers is a . (decimal point), but Django # will always use DECIMAL_SEPARATOR for any number.
comment:21 by , 5 months ago
Swiss guy here.
Keep in mind that just because the goverment specifies some formatting for governmental publications doesn't mean the rest of the country uses it.
Commonly used in IT and default swiss locale settings on current operating systems is '.' as decimal separator for ALL values (see https://de.wikipedia.org/wiki/Dezimaltrennzeichen#Schweiz )
Im IT-Bereich ist in heute gängigen Betriebssystemen (Windows, macOS, Linux usw.) in der schweizspezifischen Spracheinstellung der Punkt als Dezimaltrennzeichen definiert, auf dem Ziffernblock schweizerischer Tastaturen wird ebenfalls der Punkt verwendet.
So my vote is: change DECIMAL_SEPARATOR to '.' and ignore the government link and refer to wikipedia in the documentation.
The removal of USE_L10N and this "wrong" locale gave me quite some headaches when we upgraded from 2.2 to 5.0 just now.
Glad I finally found out how to override this in a custom format file (https://docs.djangoproject.com/en/5.0/topics/i18n/formatting/#creating-custom-format-files)
comment:22 by , 3 months ago
Owner: | changed from | to
---|
comment:23 by , 3 months ago
My mother tongue is swiss german. I agree with romibi here but I don't have strong feelings either way. Like Claude I also have a preference towards using . and not , as the decimal separator, it seems to be more common, and using a comma often leads to questions from clients.
comment:25 by , 2 months ago
Patch needs improvement: | set |
---|
As far as I'm aware, both the documentation and comments match.
So for non-monetary numbers, a comma is used for decimal and a space for thousand separators, exactly the same format is documented.