We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
babel.dates.format_timedelta throws KeyError exception on certain locale. Version 2.7.0
babel.dates.format_timedelta
KeyError
locale
from datetime import timedelta import babel from babel.core import Locale from babel.dates import format_timedelta def try_format(locale): try: format_timedelta( timedelta(hours=1), granularity="hour", threshold=float("inf"), format="narrow", locale=locale, ) return True except Exception as e: print('%s => %s: %s' % (locale, e.__class__.__name__, e)) return False from babel.localedata import locale_identifiers failed = 0 for locale in sorted(locale_identifiers()): if not try_format(locale): failed += 1
hr => KeyError: 'one' hr_BA => KeyError: 'one' hr_HR => KeyError: 'one' pt => KeyError: 'one' pt_BR => KeyError: 'one'
No KeyError exception.
The text was updated successfully, but these errors were encountered:
Hi! The KeyError problem was fixed by #827, but not all of those locales have narrow data, so format_timedelta() would return an empty string.
narrow
format_timedelta()
Sorry, something went wrong.
With #827 merged (i.e. with Babel 3.10), the repro script doesn't raise exceptions. Thank you for the report!
No branches or pull requests
Overview Description
babel.dates.format_timedelta
throwsKeyError
exception on certainlocale
. Version 2.7.0Steps to Reproduce
Actual Results
Expected Results
No
KeyError
exception.The text was updated successfully, but these errors were encountered: