Skip to content

Commit b3ac8b9

Browse files
committed
initial commit for rework
changes from original Babel PR python-babel#660 python-babel#660
1 parent fb1c19c commit b3ac8b9

File tree

4 files changed

+980
-1
lines changed

4 files changed

+980
-1
lines changed

babel/numbers.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,21 @@
2626
import warnings
2727
from typing import Any, Literal, cast, overload
2828

29+
<<<<<<< HEAD
2930
from babel.core import Locale, default_locale, get_global
3031
from babel.localedata import LocaleDataDict
32+
=======
33+
from babel.core import default_locale, Locale, get_global
34+
from babel.rbnf import RuleBasedNumberFormat
35+
36+
try:
37+
# Python 2
38+
long
39+
except NameError:
40+
# Python 3
41+
long = int
42+
43+
>>>>>>> e626e83 (initial commit for rework)
3144

3245
LC_MONETARY = default_locale(('LC_MONETARY', 'LC_NUMERIC'))
3346
LC_NUMERIC = default_locale('LC_NUMERIC')
@@ -1023,6 +1036,26 @@ def __init__(self, message: str, suggestions: list[str] | None = None) -> None:
10231036
SPACE_CHARS_RE = re.compile('|'.join(SPACE_CHARS))
10241037

10251038

1039+
def spell_number(number, locale=LC_NUMERIC, **kwargs):
1040+
"""Return value spelled out for a specific locale
1041+
1042+
:param number: the number to format
1043+
:param locale: the `Locale` object or locale identifier
1044+
:param kwargs: optional locale specific parameters
1045+
"""
1046+
speller = RuleBasedNumberFormat.negotiate(locale)
1047+
return speller.format(number, **kwargs)
1048+
1049+
1050+
def get_rbnf_rules(locale=LC_NUMERIC):
1051+
"""Return all the available public rules for a specific locale
1052+
1053+
:param locale: the `Locale` object or locale identifier
1054+
"""
1055+
speller = RuleBasedNumberFormat.negotiate(locale)
1056+
return speller.available_rulesets
1057+
1058+
10261059
def parse_number(
10271060
string: str,
10281061
locale: Locale | str | None = None,

0 commit comments

Comments
 (0)