From 6f5076db8bcc07e34622b8ce693263d0d3810726 Mon Sep 17 00:00:00 2001 From: raghav-sharma-ai Date: Sun, 4 Oct 2026 23:04:47 +0530 Subject: [PATCH] docs: correct locale activation return type and thread scope Document the translation object returned by activate() and clarify that activation and deactivation apply to the calling thread. Prepared with AI assistance (OpenAI Codex). --- src/humanize/i18n.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/humanize/i18n.py b/src/humanize/i18n.py index 672dddc5..8422e9d6 100644 --- a/src/humanize/i18n.py +++ b/src/humanize/i18n.py @@ -61,7 +61,8 @@ def activate( ) -> gettext_module.NullTranslations: """Activate internationalisation. - Set `locale` as current locale. Search for locale in directory `path`. + Set `locale` as the current locale for the calling thread. Search for locale + in directory `path`. Args: locale (str | None): Language name, e.g. `en_GB`. If `None`, defaults to no @@ -69,7 +70,7 @@ def activate( path (str | pathlib.Path): Path to search for locales. Returns: - dict: Translations. + gettext.NullTranslations: Translation object for the selected locale. Raises: FileNotFoundError: If humanize cannot find the locale folder. @@ -95,7 +96,7 @@ def activate( def deactivate() -> None: - """Deactivate internationalisation.""" + """Deactivate internationalisation for the calling thread.""" _CURRENT.locale = None