From 25f2a5827a40f0ca0f662ecad1c810c20fd596ff Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 24 Apr 2022 14:18:26 +0530 Subject: [PATCH] Ensure _locale is always set to a locale for which ICU has a collator --- src/calibre/utils/icu.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/icu.py b/src/calibre/utils/icu.py index fba0ff42ae..7b63d09528 100644 --- a/src/calibre/utils/icu.py +++ b/src/calibre/utils/icu.py @@ -72,7 +72,8 @@ def collator(strength=None, numeric=None, ignore_alternate_chars=None, upper_fir ans = _icu.Collator(_locale) except Exception as e: print(f'Failed to load collator for locale: {_locale!r} with error {e!r}, using English', file=sys.stderr) - ans = _icu.Collator('en') + _locale = 'en' + ans = _icu.Collator(_locale) else: ans = collator().clone() if strength is not None: