sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

If the language is ja, the following warning will occur. Warning: :1: (warning/2) Text or phrase interpreted inline refers to a starting string without an ending string. [document]

Open nomura-kei opened this issue 1 year ago • 1 comments

Describe the bug

If the language is ja, the following warning will occur. Warning: :1: (warning/2) Text or phrase interpreted inline refers to a starting string without an ending string. [document]

sphinx/locale/ja/LC_MESSAGES/sphinx.po:4083 NG: msgstr "%sの別名です。" OK: msgstr "%s の別名です。"

How to Reproduce

+-boo.py
+-docs/
    +-Makefile
    +-build/
    +-make.bat
    +-source/
         +-conf.py
         +-index.rst

boo.py

class Boo:
    pass

class Foo:
    boo = Boo

conf.py

import os
import sys
sys.path.insert(0, os.path.abspath("../.."))
project = 'test'
copyright = '2025, test'
author = 'test'
release = '0.0.1'
extensions = [
    'sphinx.ext.autodoc',
]
templates_path = ['_templates']
exclude_patterns = []

# !!! Occurs only when language = 'ja' !!!
language = 'ja'

html_theme = 'alabaster'
html_static_path = ['_static']

index.rst

.. test documentation master file, created by
   sphinx-quickstart on Sun Feb  2 20:40:46 2025.
   You can adapt this file completely to your liking, but it should at least
   contain the root `toctree` directive.

test documentation
==================

Add your content using ``reStructuredText`` syntax. See the
`reStructuredText <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
documentation for details.


.. toctree::
   :maxdepth: 2
   :caption: Contents:

   modules
   boo

command

sphinx-apidoc -o docs/source .
sphinx-build -v -b html -E docs/source docs/build

Environment Information

Platform:              linux; (Linux-6.1.0-30-amd64-x86_64-with-glibc2.36)
Python version:        3.13.1 (main, Jan 31 2025, 23:29:17) [GCC 12.2.0])
Python implementation: CPython
Sphinx version:        8.1.3
Docutils version:      0.21.2
Jinja2 version:        3.1.5
Pygments version:      2.19.1

Sphinx extensions

extensions = [
    'sphinx.ext.autodoc',
]

Additional context

No response

nomura-kei avatar Feb 02 '25 13:02 nomura-kei

There is a known difficulty with Japanese (and other languages that don't use whitespace to separate words) and Docutil's inline markup recognition rules 6. and 7.

sphinx/locale/ja/LC_MESSAGES/sphinx.po:4083 NG: msgstr "%sの別名です。" OK: msgstr "%s の別名です。"

I don't know the details of the translation framework, but you may try with an escaped whitespace:

msgstr "%s\ の別名です。"

The escaping backslash may need to be doubled (or even quadrupled) to reach the rST parser:

msgstr "%s\\ の別名です。"

gmilde avatar Jun 10 '25 22:06 gmilde