Skip to content

refactor: Deprecate locale option in favor of mkdocstrings' #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/usage/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ plugins:
[__all__]: https://docs.python.org/3/tutorial/modules.html#importing-from-a-package

[](){#setting-locale}
#### `locale`
#### ~~`locale`~~

The locale to use when translating template strings. The translation system is not fully ready yet, so we don't recommend setting the option for now.
**Deprecated.** Use mkdocstrings' own `locale` setting.

~~The locale to use when translating template strings.~~

[](){#setting-paths}
#### `paths`
Expand Down
4 changes: 3 additions & 1 deletion src/mkdocstrings_handlers/python/_internal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,9 @@ class PythonInputConfig:

locale: Annotated[
str | None,
_Field(description="The locale to use when translating template strings."),
_Field(
description="Deprecated. Use mkdocstrings' own `locale` setting instead. The locale to use when translating template strings.",
),
] = None

@classmethod
Expand Down
7 changes: 5 additions & 2 deletions src/mkdocstrings_handlers/python/_internal/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,12 +278,13 @@ def collect(self, identifier: str, options: PythonOptions) -> CollectorItem:

return doc_object

def render(self, data: CollectorItem, options: PythonOptions) -> str:
def render(self, data: CollectorItem, options: PythonOptions, locale: str | None = None) -> str:
"""Render the collected data.

Parameters:
data: The collected data.
options: The options to use for rendering.
locale: The locale to use for rendering (default is "en").

Returns:
The rendered data (HTML).
Expand All @@ -300,7 +301,8 @@ def render(self, data: CollectorItem, options: PythonOptions) -> str:
# than as an item in a dictionary.
"heading_level": options.heading_level,
"root": True,
"locale": self.config.locale,
# YORE: Bump 2: Regex-replace ` or .+` with ` or "en",` within line.
"locale": locale or self.config.locale,
},
)

Expand Down Expand Up @@ -401,6 +403,7 @@ def get_handler(
Parameters:
handler_config: The handler configuration.
tool_config: The tool (SSG) configuration.
**kwargs: Additional arguments to pass to the handler.

Returns:
An instance of `PythonHandler`.
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy