Allow use of importlib.metadata for finding entrypoints (#1102)
* Support importlib.metadata for finding entrypoints
* Add a basic interoperability test for Jinja2 extraction
* Only use importlib.metadata on Python 3.10+
Avoid crashing on importing `babel.localtime` when TZ envvar is malformed (#1100)
When `pytz` is _not_ installed, importing `babel.localtime` could fail
(repeatedly) when the `TZ` environment variable is malformed enough to be
caught by `_validate_tzfile_path`, which might throw a certain `ValueError`.
(When `pytz` is installed, it would raise an `UnknownTimeZoneError` we
already catch and ignore for the same sort of input.)
Tomas R [Thu, 11 Jul 2024 06:11:04 +0000 (08:11 +0200)]
Make pgettext search plurals when translation is not found (#1085)
pgettext can now find the following translation
when using `pgettext("ctx", "foo")`:
```
msgctxt "ctx"
msgid "foo"
msgid_plural "foos"
msgstr[0] "foo translated"
```
The upstream CPython PR is https://github.com/python/cpython/pull/107118
Tomas R [Thu, 11 Jul 2024 06:10:19 +0000 (08:10 +0200)]
Upgrade to CLDR 45 (#1077)
* Upgrade to CLDR 45
* Handle 'localeRules="nonlikelyScript"' for parent locales
Locales of the form 'lang_Script' where 'Script' is not the
likely script for 'lang' should have 'root' as their parent
locale. For example, the parent of 'az_Arab' should not be
computed as 'az' by truncating from the end, but should be
'root' instead as 'Arab' is not the likely script for 'az'.
The list of such languages was previously specified using
an explicit 'locales' attribute. It is now handled dynamically
using the new 'localeRules' attribute.
Allow alternative space characters as group separator when parsing numbers (#1007)
The French group separator is `"\u202f"` (narrow non-breaking space),
but when parsing numbers in the real world, you will most often encounter
either a regular space character (`" "`) or a non-breaking space character
(`"\xa0"`).
The issue was partially adressed earlier in https://github.com/python-babel/babel/issues/637,
but only to allow regular spaces instead of non-breaking spaces `"\xa0"` in
`parse_decimal`.
This commit goes further by changing both `parse_number` and `parse_decimal`
to allow certain other space characters when the group character is itself a space character,
but is not present in the string to parse.
Teo [Tue, 28 Nov 2023 09:18:50 +0000 (11:18 +0200)]
Add support for non-Latin numbering systems for number symbols (#1036)
- Import number symbols for available numbering systems from cldr data
- Add default_numbering_system and other_numbering_systems properties for Locale
- Add numbering_system argument to relevant number formatting fuctions and use number symbols based on the given numbering system
Aarni Koskela [Sun, 1 Oct 2023 11:15:51 +0000 (14:15 +0300)]
Renovate CI & tools (#1028)
* Update ruff, run autofix
* CI: Update action versions
* CI: Unify workflow files
* CI: Test on Python 3.12 too
* CI: use Ubuntu 22.04 instead of 20.04
* CI: add publish step for version tags
Petr Viktorin [Sun, 1 Oct 2023 10:52:33 +0000 (12:52 +0200)]
Add f-string parsing for Python 3.12 (PEP 701) (#1027)
Since Python 3.12, f-strings are tokenized and parsed like the rest
of Python's grammar, using the new tokens FSTRING_START, FSTRING_MIDDLE
and FSTRING_END.
Make the babel message extractor concatenate these three if they're
adjacent to each other. If they're not, that means there are dynamic
substitutions, so the f-string is ignored.
Michał Górny [Tue, 9 May 2023 08:20:04 +0000 (10:20 +0200)]
Freeze format_time() tests to a specific date to fix test failures (#998)
Freeze the date when performing the tests for format_time() with
a timezone specified. Since the time object does not specify a date,
the formatter uses the format string specific to the current date.
As a result, if the current DST state is different than when the test
was last updated, it failed.
Jean Abou Samra [Sun, 12 Feb 2023 01:46:30 +0000 (02:46 +0100)]
In fuzzy matching, also .lower().strip() fuzzy candidates
This seems intended at easing fuzzy matching with trivial edits in the
msgstr (changing case and adding whitespace), but it was only done on
the new msgstr, not on the old mgstr candidates, so it was possible for
merging catalogs to miss messages.
martin f. krafft [Thu, 26 Jan 2023 17:46:06 +0000 (18:46 +0100)]
Keep @modifiers when parsing locales (#947)
Locale modifiers ("@variants") are described in the GNU gettext
documentation like this:
> The ‘@variant’ can denote any kind of characteristics that is not
> already implied by the language ll and the country CC. […] It can also
> denote a dialect of the language, …
Wherein Babel previously would discard these, this patch stores the
modifier information in the `Locale` objects, handling string
representation accordingly.
Resolves: #946 Signed-off-by: martin f. krafft <madduck@madduck.net> Co-authored-by: Aarni Koskela <akx@iki.fi>