Skip to content

Commit 17f71ba

Browse files
authored
refactor: Deprecate locale option in favor of mkdocstrings'
PR-288: #288
1 parent a1bce97 commit 17f71ba

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

docs/usage/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,11 @@ plugins:
150150
[__all__]: https://docs.python.org/3/tutorial/modules.html#importing-from-a-package
151151

152152
[](){#setting-locale}
153-
#### `locale`
153+
#### ~~`locale`~~
154154

155-
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.
155+
**Deprecated.** Use mkdocstrings' own `locale` setting.
156+
157+
~~The locale to use when translating template strings.~~
156158

157159
[](){#setting-paths}
158160
#### `paths`

src/mkdocstrings_handlers/python/_internal/config.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,9 @@ class PythonInputConfig:
10351035

10361036
locale: Annotated[
10371037
str | None,
1038-
_Field(description="The locale to use when translating template strings."),
1038+
_Field(
1039+
description="Deprecated. Use mkdocstrings' own `locale` setting instead. The locale to use when translating template strings.",
1040+
),
10391041
] = None
10401042

10411043
@classmethod

src/mkdocstrings_handlers/python/_internal/handler.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,13 @@ def collect(self, identifier: str, options: PythonOptions) -> CollectorItem:
278278

279279
return doc_object
280280

281-
def render(self, data: CollectorItem, options: PythonOptions) -> str:
281+
def render(self, data: CollectorItem, options: PythonOptions, locale: str | None = None) -> str:
282282
"""Render the collected data.
283283
284284
Parameters:
285285
data: The collected data.
286286
options: The options to use for rendering.
287+
locale: The locale to use for rendering (default is "en").
287288
288289
Returns:
289290
The rendered data (HTML).
@@ -300,7 +301,8 @@ def render(self, data: CollectorItem, options: PythonOptions) -> str:
300301
# than as an item in a dictionary.
301302
"heading_level": options.heading_level,
302303
"root": True,
303-
"locale": self.config.locale,
304+
# YORE: Bump 2: Regex-replace ` or .+` with ` or "en",` within line.
305+
"locale": locale or self.config.locale,
304306
},
305307
)
306308

@@ -401,6 +403,7 @@ def get_handler(
401403
Parameters:
402404
handler_config: The handler configuration.
403405
tool_config: The tool (SSG) configuration.
406+
**kwargs: Additional arguments to pass to the handler.
404407
405408
Returns:
406409
An instance of `PythonHandler`.

0 commit comments

Comments
 (0)
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