File tree Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Expand file tree Collapse file tree 4 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -51,8 +51,8 @@ In practice, you have to:
5151 :caption: src/ __init__ .py
5252
5353 def setup (app ):
54- package_dir = path.abspath(path.dirname( __file__ ))
55- locale_dir = os.path.join( package_dir, ' locales' )
54+ package_dir = Path( __file__ ).parent.resolve( )
55+ locale_dir = package_dir / ' locales'
5656 app.add_message_catalog(MESSAGE_CATALOG_NAME , locale_dir)
5757
5858 #. Generate message catalog template ``*.pot `` file, usually in ``locale/ ``
Original file line number Diff line number Diff line change @@ -1616,7 +1616,7 @@ def add_html_math_renderer(
16161616 """
16171617 self .registry .add_html_math_renderer (name , inline_renderers , block_renderers )
16181618
1619- def add_message_catalog (self , catalog : str , locale_dir : str ) -> None :
1619+ def add_message_catalog (self , catalog : str , locale_dir : str | os . PathLike [ str ] ) -> None :
16201620 """Register a message catalog.
16211621
16221622 :param catalog: The name of the catalog
Original file line number Diff line number Diff line change 55import locale
66import sys
77from gettext import NullTranslations , translation
8- from os import path
8+ from pathlib import Path
99from typing import TYPE_CHECKING
1010
1111if TYPE_CHECKING :
@@ -141,11 +141,11 @@ def init(
141141 return translator , has_translation
142142
143143
144- _LOCALE_DIR = path . abspath ( path . dirname ( __file__ ))
144+ _LOCALE_DIR = Path ( __file__ ). parent . resolve ( )
145145
146146
147147def init_console (
148- locale_dir : str | None = None ,
148+ locale_dir : str | os . PathLike [ str ] | None = None ,
149149 catalog : str = 'sphinx' ,
150150) -> tuple [NullTranslations , bool ]:
151151 """Initialize locale for console.
Original file line number Diff line number Diff line change 2020
2121
2222def _init_console (
23- locale_dir : str | None = sphinx .locale ._LOCALE_DIR ,
23+ locale_dir : str | os . PathLike [ str ] | None = sphinx .locale ._LOCALE_DIR ,
2424 catalog : str = 'sphinx' ,
2525) -> tuple [gettext .NullTranslations , bool ]:
2626 """Monkeypatch ``init_console`` to skip its action.
You can’t perform that action at this time.
0 commit comments