Miro Hrončok [Thu, 14 Mar 2019 18:54:42 +0000 (19:54 +0100)]
Fix conftest.py compatibility with pytest 4.3
While pytest in tox.ini is explicitly set to be 3.3.2, in Fedora 31
we are about to update to a newer version of pytest.
In order to be able to test babel, we need pytest 4.3 support.
This adds support for pytest 4.3 without breaking support for 3.3.2.
Jon Dufresne [Thu, 11 Oct 2018 03:34:09 +0000 (20:34 -0700)]
Remove unnecessary compat shim 'binary_type'
The bytes type is available on all supported Pythons. On Python 2, it is
an alias of str, same as binary_type. By removing the shim, makes the
code more forward compatible.
mondeja [Sat, 13 Oct 2018 12:49:30 +0000 (14:49 +0200)]
Avoid KeyError trying to get data on WindowsXP
I've found this issue trying to compile documentation with Sphinx on WindowsXP with `make html` command. Some data dictionaries are void on my machine, so using lazy 'get' on those can prevent next `KeyError`:
```
C:\Path\to\my\project\doc>make html
{'MapID': '8,9', 'Index': 165, 'Std': 'Hora estándar árabe', 'Display': '(GMT+04
:00) Abu Dhabi, Muscat', 'TZI': b'\x10\xff\xff\xff\x00\x00\x00\x00\xc4\xff\xff\x
ff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'Dlt': 'Hora de verano árab
e'}
{'MapID': '-1,71', 'Index': 158, 'Std': 'Hora estándar árabe D', 'Display': '(GM
T+03:00) Baghdad', 'TZI': b'L\xff\xff\xff\x00\x00\x00\x00\xc4\xff\xff\xff\x00\x0
0\n\x00\x00\x00\x01\x00\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\
x01\x00\x03\x00\x00\x00\x00\x00\x00\x00', 'Dlt': 'Hora de verano árabe'}
{'MapID': '12,13', 'Index': 195, 'Std': 'Hora estándar de Asia C.', 'Display': '
(GMT+06:00) Astana, Dhaka', 'TZI': b'\x98\xfe\xff\xff\x00\x00\x00\x00\xc4\xff\xf
f\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0
0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', 'Dlt': 'Hora de verano d
e Asia C.'}
{}
Traceback (most recent call last):
File "c:\python34\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)
File "c:\python34\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Python34\Scripts\sphinx-build.exe\__main__.py", line 5, in <module>
File "c:\python34\lib\site-packages\sphinx\cmd\build.py", line 25, in <module>
from sphinx.application import Sphinx
File "c:\python34\lib\site-packages\sphinx\application.py", line 29, in <modul
e>
from sphinx.config import Config, check_unicode
File "c:\python34\lib\site-packages\sphinx\config.py", line 28, in <module>
from sphinx.util.i18n import format_date
File "c:\python34\lib\site-packages\sphinx\util\i18n.py", line 20, in <module>
import babel.dates
File "c:\python34\lib\site-packages\babel\dates.py", line 29, in <module>
from babel.util import UTC, LOCALTZ
File "c:\python34\lib\site-packages\babel\util.py", line 19, in <module>
from babel import localtime
File "c:\python34\lib\site-packages\babel\localtime\__init__.py", line 74, in
<module>
LOCALTZ = get_localzone()
File "c:\python34\lib\site-packages\babel\localtime\__init__.py", line 70, in
get_localzone
return _get_localzone()
File "c:\python34\lib\site-packages\babel\localtime\_win32.py", line 97, in _g
et_localzone
return pytz.timezone(get_localzone_name())
File "c:\python34\lib\site-packages\babel\localtime\_win32.py", line 70, in ge
t_localzone_name
if data['Std'] == tzwin:
KeyError: 'Std'
```
Luke Plant [Thu, 7 Jun 2018 12:21:19 +0000 (15:21 +0300)]
Simplify format_currency code by pulling out/using helpers.
In detail:
1. Use the already existing get_currency_name function which does
the plural form logic already.
2. Create a similar `get_currency_unit_pattern` function.
This function could be useful if someone wanted to write
something very similar to the _format_currency_long_name
functionality but with some different customizations,
so it is now publicly documented.
3. Simplify the _format_currency_long_name function - it
is now much flatter.
4. Add more tests to ensure certain cases are really covered.
(e.g. different unit patterns depending on the count)
An upshot of the changes is that we have reduced (and made more consistent)
the number of places where we need to peek into `Locale._data` -
get_currency_name and get_currency_unit_pattern are the only places that
babel.numbers does this.
Aarni Koskela [Mon, 28 May 2018 09:12:23 +0000 (12:12 +0300)]
import_cldr: ignore formatting rules for non-Latin numbering systems
Previously the script could have inadvertently merged formatting rules between numbering systems due to the XML selectors used. This makes sure only Latin rules are used for the time being. When support for other numbering systems is properly added (see #470), these checks can be changed.
Aarni Koskela [Mon, 7 May 2018 10:01:25 +0000 (13:01 +0300)]
Restore force_frac to NumberPattern.apply(), as deprecated
This retains backwards compatibility (at least as far as the function's
signature is concerned) with users that are using NumberPattern.apply()
directly.
xmo-odoo [Fri, 26 Jan 2018 10:14:57 +0000 (11:14 +0100)]
Add explicit signatures to some date autofunctions
Because default_locale is eager, it generates misleading documentation when built (including on the site) as the doc will show the LC_TIME for the machine which built the doc.
An explicit autofunction signature fixes that and provides a more correct view of the signature.
An alternative fix would be for the LC_TIME value in the module to be a custom object with a repr of LC_TIME or something along those lines.
Aarni Koskela [Fri, 18 Aug 2017 10:14:46 +0000 (13:14 +0300)]
cldr: use CLDR 31.0.1 (and fix test changes); see below!
CLDR 31.0 separated the GMT and UTC time zones, so formatting of that
time zone has changed. Most notably, "UTC" replaces "+0000" when formatting
the timezone. This could break code that expects +0000.
A subset (the parts supported by Babel) of the migration guide from
http://cldr.unicode.org/index/downloads/cldr-31:
* The locales in the language-territory population tables have been changed to
be the canonical format, dropping the script where it is the default.
So "ku_Latn" changes to "ku".
* Plural rules: The Portuguese plural rules have changed so that all
(and only) integers and decimal fractions < 2 are singular.
* Timezones: The GMT timezone has been split from the UTC timezone.
* Timezones: New timezone bcp47 codes have been added.
* Languages "hr" and "sr" are no longer a short distance apart, for political reasons.
* The primary names for CZ changed from "Czech Republic" to
"Czechia", with the longer name now the alternate.
pofile.py: Added new exception called PoFileError and thrown if flagged
This new exception is thrown when the po parser finds an invalid pofile.
This helps handle invalid po files that are parsed. Invalid po files may cause
other possible errors such as a UnicodeEncodeError.