|
26 | 26 | import warnings |
27 | 27 | from typing import Any, Literal, cast, overload |
28 | 28 |
|
| 29 | +<<<<<<< HEAD |
29 | 30 | from babel.core import Locale, default_locale, get_global |
30 | 31 | 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) |
31 | 44 |
|
32 | 45 | LC_MONETARY = default_locale(('LC_MONETARY', 'LC_NUMERIC')) |
33 | 46 | LC_NUMERIC = default_locale('LC_NUMERIC') |
@@ -1023,6 +1036,26 @@ def __init__(self, message: str, suggestions: list[str] | None = None) -> None: |
1023 | 1036 | SPACE_CHARS_RE = re.compile('|'.join(SPACE_CHARS)) |
1024 | 1037 |
|
1025 | 1038 |
|
| 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 | + |
1026 | 1059 | def parse_number( |
1027 | 1060 | string: str, |
1028 | 1061 | locale: Locale | str | None = None, |
|
0 commit comments