Skip to content

Instantly share code, notes, and snippets.

@DenverCoder1
Created November 17, 2022 05:23
Show Gist options
  • Select an option

  • Save DenverCoder1/9c34fb012cefdc75f8d53724c24fe260 to your computer and use it in GitHub Desktop.

Select an option

Save DenverCoder1/9c34fb012cefdc75f8d53724c24fe260 to your computer and use it in GitHub Desktop.
python-babel/babel#932 locale searches
from babel.core import Locale
from babel.localedata import locale_identifiers
def find_plural_forms_with_one_where_not_appearing_in_formats():
for identifier in sorted(locale_identifiers()):
locale = Locale.parse(identifier)
short_format = locale.compact_decimal_formats.get('short', {})
long_format = locale.compact_decimal_formats.get('long', {})
if ("one" not in short_format or "one" not in long_format) and locale.plural_form(21) == "one":
print(f"{identifier}: {list(short_format.keys())} {list(long_format.keys())}")
def find_explicit_0_formats():
for identifier in sorted(locale_identifiers()):
locale = Locale.parse(identifier)
short_format = locale.compact_decimal_formats.get('short', {})
long_format = locale.compact_decimal_formats.get('long', {})
if "0" in short_format or "0" in long_format:
print(f"{identifier}: {list(short_format.keys())} {list(long_format.keys())}")
find_plural_forms_with_one_where_not_appearing_in_formats()
# ceb: ['other'] []
# ceb_PH: ['other'] []
# gv: ['other'] []
# gv_IM: ['other'] []
# tzm: ['other'] []
# tzm_MA: ['other'] []
find_explicit_0_formats() # no results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment