mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Remove `sphinx.locale.setlocale
`
This commit is contained in:
parent
7d928b3e79
commit
c7d7f2951d
1
CHANGES
1
CHANGES
@ -17,6 +17,7 @@ Incompatible changes
|
||||
now-obsolete binary distribution format
|
||||
* #11089: Remove deprecated code in ``sphinx.builders.linkcheck``.
|
||||
Patch by Daniel Eades
|
||||
* Remove internal-only ``sphinx.locale.setlocale``
|
||||
|
||||
Deprecated
|
||||
----------
|
||||
|
@ -272,7 +272,7 @@ class Sphinx:
|
||||
the configuration.
|
||||
"""
|
||||
if self.config.language == 'en':
|
||||
self.translator, has_translation = locale.init([], None)
|
||||
self.translator, _ = locale.init([], None)
|
||||
else:
|
||||
logger.info(bold(__('loading translations [%s]... ') % self.config.language),
|
||||
nonl=True)
|
||||
|
@ -16,7 +16,7 @@ from typing import Any, TextIO
|
||||
from docutils.utils import SystemMessage
|
||||
|
||||
import sphinx.locale
|
||||
from sphinx import __display_version__, package_dir
|
||||
from sphinx import __display_version__
|
||||
from sphinx.application import Sphinx
|
||||
from sphinx.errors import SphinxError
|
||||
from sphinx.locale import __
|
||||
@ -310,8 +310,8 @@ def _bug_report_info() -> int:
|
||||
|
||||
|
||||
def main(argv: list[str] = sys.argv[1:]) -> int:
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console()
|
||||
|
||||
if argv[:1] == ['--bug-report']:
|
||||
return _bug_report_info()
|
||||
|
@ -540,8 +540,8 @@ def get_parser() -> argparse.ArgumentParser:
|
||||
|
||||
|
||||
def main(argv: list[str] = sys.argv[1:]) -> int:
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console()
|
||||
|
||||
if not color_terminal():
|
||||
nocolor()
|
||||
|
@ -392,8 +392,8 @@ Note: By default this script will not overwrite already created files."""))
|
||||
|
||||
def main(argv: list[str] = sys.argv[1:]) -> int:
|
||||
"""Parse and check the command line arguments."""
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console()
|
||||
|
||||
parser = get_parser()
|
||||
args = parser.parse_args(argv)
|
||||
|
@ -636,11 +636,10 @@ The format of the autosummary directive is documented in the
|
||||
|
||||
|
||||
def main(argv: list[str] = sys.argv[1:]) -> None:
|
||||
sphinx.locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console(os.path.join(package_dir, 'locale'), 'sphinx')
|
||||
translator, _ = sphinx.locale.init([], None)
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
sphinx.locale.init_console()
|
||||
|
||||
app = DummyApplication(translator)
|
||||
app = DummyApplication(sphinx.locale.get_translator())
|
||||
logging.setup(app, sys.stdout, sys.stderr) # type: ignore
|
||||
setup_documenters(app)
|
||||
args = get_parser().parse_args(argv)
|
||||
|
@ -3,7 +3,7 @@
|
||||
import locale
|
||||
from gettext import NullTranslations, translation
|
||||
from os import path
|
||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
|
||||
from typing import Any, Callable, Dict, List, Optional, Tuple
|
||||
|
||||
|
||||
class _TranslationProxy:
|
||||
@ -138,26 +138,6 @@ def init(
|
||||
return translator, has_translation
|
||||
|
||||
|
||||
def setlocale(category: int, value: Union[str, Iterable[str], None] = None) -> None:
|
||||
"""Update locale settings.
|
||||
|
||||
This does not throw any exception even if update fails.
|
||||
This is workaround for Python's bug.
|
||||
|
||||
For more details:
|
||||
|
||||
* https://github.com/sphinx-doc/sphinx/issues/5724
|
||||
* https://bugs.python.org/issue18378#msg215215
|
||||
|
||||
.. note:: Only for internal use. Please don't call this method from extensions.
|
||||
This will be removed in Sphinx 6.0.
|
||||
"""
|
||||
try:
|
||||
locale.setlocale(category, value)
|
||||
except locale.Error:
|
||||
pass
|
||||
|
||||
|
||||
_LOCALE_DIR = path.abspath(path.dirname(__file__))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user