Opened 4 months ago

Last modified 4 months ago

#35095 assigned Cleanup/optimization

Monetary values in Switzerland discrepancy

Reported by: Andrea Angelini Owned by: Neil Pendyala
Component: Internationalization Version: 5.0
Severity: Normal Keywords:
Cc: Claude Paroz, Silvan Spross Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
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 (20)

comment:1 by Mariusz Felisiak, 4 months ago

Cc: Claude Paroz added
Component: DocumentationInternationalization
Resolution: invalid
Status: newclosed

As far as I'm aware, both the documentation and comments match.

# These are the separators for non-monetary numbers. For monetary numbers,
# the DECIMAL_SEPARATOR is a . (decimal point) and the THOUSAND_SEPARATOR is a
# ' (single quote).
DECIMAL_SEPARATOR = ","
THOUSAND_SEPARATOR = "\xa0" # non-breaking space

So for non-monetary numbers, a comma is used for decimal and a space for thousand separators, exactly the same format is documented.

comment:2 by Andrea Angelini, 4 months ago

Resolution: invalid
Status: closednew

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)".

Last edited 4 months ago by Andrea Angelini (previous) (diff)

in reply to:  2 ; comment:3 by Mariusz Felisiak, 4 months ago

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/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 Mariusz Felisiak, 4 months ago

Cc: Silvan Spross added

in reply to:  3 comment:5 by Himateju V, 4 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 Neil Pendyala, 4 months ago

Owner: changed from nobody to Neil Pendyala
Status: newassigned

comment:7 by Neil Pendyala, 4 months ago

Has patch: set

comment:8 by Mariusz Felisiak, 4 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?

comment:9 by Alexander Lazarević, 4 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 Alexander Lazarević, 4 months ago

Has patch: set
Patch needs improvement: set

comment:11 by Andrea Angelini, 4 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

in reply to:  9 ; comment:12 by Mariusz Felisiak, 4 months ago

Replying to Alexander Lazarević:

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.

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."

in reply to:  12 comment:13 by Andrea Angelini, 4 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).

Last edited 4 months ago by Andrea Angelini (previous) (diff)

comment:14 by Mariusz Felisiak, 4 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 Mariusz Felisiak, 4 months ago

Has patch: unset
Patch needs improvement: unset

comment:16 by Claude Paroz, 4 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.

in reply to:  12 comment:17 by Alexander Lazarević, 4 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.

in reply to:  16 comment:18 by Alexander Lazarević, 4 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 Alexander Lazarević, 4 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 Alexander Lazarević, 4 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.
Note: See TracTickets for help on using tickets.
Back to Top