FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

babel.lists.format_list errors on 'standard-narrow' style for German locale · Issue #781 · python-babel/babel · GitHub

Repository navigation

babel.lists.format_list errors on 'standard-narrow' style for German locale #781

Open

Description

Steps to Reproduce

from babel.lists import format_list
format_list(['A', 'B', 'C'], style='standard-narrow', locale='de')

Actual Results

Traceback (most recent call last):
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-fdcd09f7f101>", line 1, in <module>
    format_list(['A', 'B', 'C'], style='standard-narrow', locale='de')
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\babel\lists.py", line 82, in format_list
    result = patterns['start'].format(lst[0], lst[1])
File "C:\Users\amelia.bruno\PycharmProjects\orion\prompt-generators\pg-sport\venv\lib\site-packages\babel\localedata.py", line 218, in __getitem__
    orig = val = self._data[key]
KeyError: 'start'

Expected Results

The english locale gives the expected result:

format_list(['A', 'B', 'C'], style='standard-narrow', locale='en')
Out[4]: 'A, B, C'

Activity

  1. jithenms commented on Apr 24, 2021

    I believe that standard-narrow isn't a type of style available on babel. The key to fixing this issue might be to use one of the styles listed on their documentation page here.

    Revised Code

    from babel.lists
    import format_list
    format_list(['A', 'B', 'C'], style='unit-narrow', locale='de')

    Or

    format_list(['A', 'B', 'C'], style='standard', locale='de')

    Take a look at their documentation page to see what might fit your use case best.

  2. amelia-bruno commented on Apr 26, 2021

    Author

    Thanks for the reference. I'll do that, but I'm curious as to why the 'standard-narrow' style does work for the English locale, despite it being omitted from the documentation. And in any case there is a gap between the functionality and the documentation that ought to be fixed. Does anyone know why it was implemented that way for English?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL