Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

German number separators not working using format language and locale "de_DE" #61148

Closed
PeterStahl mannequin opened this issue Jan 12, 2013 · 6 comments
Closed

German number separators not working using format language and locale "de_DE" #61148

PeterStahl mannequin opened this issue Jan 12, 2013 · 6 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@PeterStahl
Copy link
Mannequin

PeterStahl mannequin commented Jan 12, 2013

BPO 16944
Nosy @mdickinson, @ericvsmith, @skrah

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-01-14.16:49:42.780>
created_at = <Date 2013-01-12.11:26:56.258>
labels = ['invalid', 'type-bug', 'library']
title = 'German number separators not working using format language and locale "de_DE"'
updated_at = <Date 2013-01-14.16:49:42.779>
user = 'https://bugs.python.org/PeterStahl'

bugs.python.org fields:

activity = <Date 2013-01-14.16:49:42.779>
actor = 'skrah'
assignee = 'none'
closed = True
closed_date = <Date 2013-01-14.16:49:42.780>
closer = 'skrah'
components = ['Library (Lib)']
creation = <Date 2013-01-12.11:26:56.258>
creator = 'Peter.Stahl'
dependencies = []
files = []
hgrepos = []
issue_num = 16944
keywords = []
message_count = 6.0
messages = ['179785', '179787', '179788', '179789', '179951', '179953']
nosy_count = 4.0
nosy_names = ['mark.dickinson', 'eric.smith', 'skrah', 'Peter.Stahl']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue16944'
versions = ['Python 2.6', 'Python 3.1', 'Python 2.7', 'Python 3.2', 'Python 3.3']

@PeterStahl
Copy link
Mannequin Author

PeterStahl mannequin commented Jan 12, 2013

Yesterday, I opened a question on Stackoverflow that explains my problem in detail. Please read this page first:

http://stackoverflow.com/questions/14287051/german-number-separators-using-format-language-on-osx

A short summary: I'm on OSX 10.8.2. I wanted to format numbers according to the German numbering convention using Python's format language and the locale setting "de_DE". Actually, the following should work to achieve that:

>> import locale
>> locale.setlocale(locale.LC_ALL, 'de_DE')
>> '{0:n}'.format(1234.56)

The result of the last expressions should be 1.234,56. However, my result is 1234,56. More examples are on Stackoverflow.

According to what other SO members have found out, this is a problem with the locale settings of OSX because the grouping of numbers is not fully part of the locale "de_DE". On Windows, however, grouping works fine using the locale "deu_deu" which is not available on OSX.

Is this a bug? At least, it doesn't seem to be documented anywhere and is probably not the correct behavior even on OSX. Others have reported similar problems on OSX as well.

Do you have a quick solution for this issue? Thanks in advance.

@PeterStahl PeterStahl mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Jan 12, 2013
@skrah
Copy link
Mannequin

skrah mannequin commented Jan 12, 2013

What is the output of this?

>>> locale.localeconv()                     
{'mon_decimal_point': ',', 'frac_digits': 2, 'p_sign_posn': 1, 'thousands_sep': '.', 'p_sep_by_space': 1, 'int_curr_symbol': 'EUR ', 'decimal_point': ',', 'mon_thousands_sep': '.', 'n_sep_by_space': 1, 'int_frac_digits': 2, 'currency_symbol': 'EUR', 'negative_sign': '-', 'mon_grouping': [3, 3, 0], 'positive_sign': '', 'n_cs_precedes': 0, 'grouping': [3, 3, 0], 'n_sign_posn': 1, 'p_cs_precedes': 0}

If 'grouping' is [], then this looks like a bug in OSX. Python gets
the values directly from the operating system.

@PeterStahl
Copy link
Mannequin Author

PeterStahl mannequin commented Jan 12, 2013

Using the locale 'de_DE', the output is:

{'mon_decimal_point': ',', 'int_frac_digits': 2, 'p_sep_by_space': 0, 'frac_digits': 2, 'thousands_sep': '', 'n_sign_posn': 1, 'decimal_point': ',', 'int_curr_symbol': 'EUR ', 'n_cs_precedes': 1, 'p_sign_posn': 1, 'mon_thousands_sep': '.', 'negative_sign': '-', 'currency_symbol': 'Eu', 'n_sep_by_space': 0, 'mon_grouping': [3, 3, 0], 'p_cs_precedes': 1, 'positive_sign': '', 'grouping': [127]}

What does the number 127 mean?

Am 12.01.2013 um 12:39 schrieb Stefan Krah <report@bugs.python.org>:

Stefan Krah added the comment:

What is the output of this?

>>> locale.localeconv()
{'mon_decimal_point': ',', 'frac_digits': 2, 'p_sign_posn': 1, 'thousands_sep': '.', 'p_sep_by_space': 1, 'int_curr_symbol': 'EUR ', 'decimal_point': ',', 'mon_thousands_sep': '.', 'n_sep_by_space': 1, 'int_frac_digits': 2, 'currency_symbol': 'EUR', 'negative_sign': '-', 'mon_grouping': [3, 3, 0], 'positive_sign': '', 'n_cs_precedes': 0, 'grouping': [3, 3, 0], 'n_sign_posn': 1, 'p_cs_precedes': 0}

If 'grouping' is [], then this looks like a bug in OSX. Python gets
the values directly from the operating system.

----------
nosy: +skrah
status: open -> pending


Python tracker <report@bugs.python.org>
<http://bugs.python.org/issue16944\>


@skrah
Copy link
Mannequin

skrah mannequin commented Jan 12, 2013

127 means "no-more-grouping", so Python behaves as instructed by the OS.

As you see, the OS prescribes 1.345.677,222 for *monetary* quantities
and 1345677,222 otherwise.

According to http://de.wikipedia.org/wiki/DIN_1333 , for non monetary
quantities DIN-1333 says *empty spaces* *may* be used as separators.
DIN-5008 says they *should* be used. :)

Most operating systems use [3, 3, 0] also for de_DE 'grouping', but
given the unclear situation it's hard to claim a bug in OSX.

The only way out of this would be to introduce a new 'm' locale specifier
that uses mon_grouping.

@ericvsmith
Copy link
Member

I think this issue should be closed, since we're doing as we're instructed by the OS. If someone wants to open a new issue for the "m" format specifier type, I'd support that.

@skrah
Copy link
Mannequin

skrah mannequin commented Jan 14, 2013

I agree, we can't really do anything here.

@skrah skrah mannequin closed this as completed Jan 14, 2013
@skrah skrah mannequin added the invalid label Jan 14, 2013
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

1 participant