Skip to content
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

Failed to translate the content of ‘parsed-literal’ directive with hyperlinks in cmake.1.rst #12278

Closed
hwhsu1231 opened this issue Apr 14, 2024 · 2 comments

Comments

@hwhsu1231
Copy link

Describe the bug

Hello, Sphinx Maintainace Team.

This issue is related to:

In short, I tried to translate CMake Documentation with its Gettext PO files generated by gettext builder. However, I still cannot figure out how to translate this part of cmake.rst, in which there exist hyperlinks in the parsed-literal directive.

I started to think whether it is a bug from Sphinx itself? If not, how should I translate it?

How to Reproduce

  1. Download the demo project:

    https://www.terabox.com/taiwan/sharing/link?surl=5okvTcrcnl4gO_i1mW6nJw

  2. Run the following commands in order:

    tar -zxf cmake-v3.28.4.tar.gz
    cd cmake-v3.28.4
    python -m venv .venv
    source .venv/bin/activate
    pip install sphinx==6.2.1 --progress-bar off
    LANG=en_US.UTF-8 sphinx-build -b html -D locale_dirs=locale -D language=zh_TW -D gettext_compact=0 -D 
    gettext_additional_targets=index,literal-block Help _build
    firefox _build/manual/cmake.1.html

Environment Information

Platform:              linux; (Linux-6.5.0-26-generic-x86_64-with-glibc2.35)
Python version:        3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        6.2.1
Docutils version:      0.19
Jinja2 version:        3.1.3
Pygments version:      2.17.2

Sphinx extensions

No response

Additional context

The full log of 'How to Reproduce' is as below:

Click to expand the full log
hwhsu1231@vb-kubuntu:~/Repo/testing$ tar -zxf cmake-v3.28.4.tar.gz
hwhsu1231@vb-kubuntu:~/Repo/testing$ cd cmake-v3.28.4
hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ python -m venv .venv
hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ source .venv/bin/activate
(.venv) hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ pip install sphinx==6.2.1 --progress-bar off
Collecting sphinx==6.2.1
  Using cached sphinx-6.2.1-py3-none-any.whl (3.0 MB)
Collecting packaging>=21.0
  Using cached packaging-24.0-py3-none-any.whl (53 kB)
Collecting sphinxcontrib-htmlhelp>=2.0.0
  Using cached sphinxcontrib_htmlhelp-2.0.5-py3-none-any.whl (99 kB)
Collecting alabaster<0.8,>=0.7
  Using cached alabaster-0.7.16-py3-none-any.whl (13 kB)
Collecting requests>=2.25.0
  Using cached requests-2.31.0-py3-none-any.whl (62 kB)
Collecting sphinxcontrib-applehelp
  Using cached sphinxcontrib_applehelp-1.0.8-py3-none-any.whl (120 kB)
Collecting docutils<0.20,>=0.18.1
  Using cached docutils-0.19-py3-none-any.whl (570 kB)
Collecting Jinja2>=3.0
  Using cached Jinja2-3.1.3-py3-none-any.whl (133 kB)
Collecting babel>=2.9
  Using cached Babel-2.14.0-py3-none-any.whl (11.0 MB)
Collecting sphinxcontrib-qthelp
  Using cached sphinxcontrib_qthelp-1.0.7-py3-none-any.whl (89 kB)
Collecting sphinxcontrib-jsmath
  Using cached sphinxcontrib_jsmath-1.0.1-py2.py3-none-any.whl (5.1 kB)
Collecting imagesize>=1.3
  Using cached imagesize-1.4.1-py2.py3-none-any.whl (8.8 kB)
Collecting Pygments>=2.13
  Using cached pygments-2.17.2-py3-none-any.whl (1.2 MB)
Collecting sphinxcontrib-devhelp
  Using cached sphinxcontrib_devhelp-1.0.6-py3-none-any.whl (83 kB)
Collecting snowballstemmer>=2.0
  Using cached snowballstemmer-2.2.0-py2.py3-none-any.whl (93 kB)
Collecting sphinxcontrib-serializinghtml>=1.1.5
  Using cached sphinxcontrib_serializinghtml-1.1.10-py3-none-any.whl (92 kB)
Collecting MarkupSafe>=2.0
  Using cached MarkupSafe-2.1.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting charset-normalizer<4,>=2
  Using cached charset_normalizer-3.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)
Collecting urllib3<3,>=1.21.1
  Using cached urllib3-2.2.1-py3-none-any.whl (121 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2024.2.2-py3-none-any.whl (163 kB)
Collecting idna<4,>=2.5
  Using cached idna-3.6-py3-none-any.whl (61 kB)
Installing collected packages: snowballstemmer, urllib3, sphinxcontrib-serializinghtml, sphinxcontrib-qthelp, sphinxcontrib-jsmath, sphinxcontrib-htmlhelp, sphinxcontrib-devhelp, sphinxcontrib-applehelp, Pygments, packaging, MarkupSafe, imagesize, idna, docutils, charset-normalizer, certifi, babel, alabaster, requests, Jinja2, sphinx
Successfully installed Jinja2-3.1.3 MarkupSafe-2.1.5 Pygments-2.17.2 alabaster-0.7.16 babel-2.14.0 certifi-2024.2.2 charset-normalizer-3.3.2 docutils-0.19 idna-3.6 imagesize-1.4.1 packaging-24.0 requests-2.31.0 snowballstemmer-2.2.0 sphinx-6.2.1 sphinxcontrib-applehelp-1.0.8 sphinxcontrib-devhelp-1.0.6 sphinxcontrib-htmlhelp-2.0.5 sphinxcontrib-jsmath-1.0.1 sphinxcontrib-qthelp-1.0.7 sphinxcontrib-serializinghtml-1.1.10 urllib3-2.2.1
(.venv) hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ LANG=en_US.UTF-8 sphinx-build -b html -D locale_dirs=locale -D language=zh_TW -D gettext_compact=0 -D gettext_additional_targets=index,literal-block Help _build
Running Sphinx v6.2.1
loading translations [zh_TW]... done
making output directory... done
building [mo]: targets for 0 po files that are out of date
writing output... 
building [html]: targets for 1997 source files that are out of date
updating environment: [new config] 1997 added, 0 changed, 0 removed
reading sources... [100%] variable/XCODE_VERSION                                                                                                                                           
/home/hwhsu1231/Repo/testing/cmake-v3.28.4/Help/manual/cmake.1.rst:11: WARNING: inconsistent references in translated message. original: ['`Generate a Project Buildsystem`_', '`Build a Project`_', '`Install a Project`_', '`Open a Project`_', '`Run a Script`_', '`Run a Command-Line Tool`_', '`Run the Find-Package Tool`_', '`Run a Workflow Preset`_', '`View Help`_'], translated: []
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] variable/XCODE_VERSION                                                                                                                                            
generating indices... genindex done
writing additional pages... search done
copying images... [100%] guide/user-interaction/GUI-Add-Entry.png                                                                                                                          
copying downloadable files... [100%] manual/presets/schema.json                                                                                                                            
copying static files... done
copying extra files... done
dumping search index in Chinese (code: zh)... done
dumping object inventory... done
build succeeded, 1 warning.

The HTML pages are in _build.
(.venv) hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ firefox _build/manual/cmake.1.html
[Parent 3713910, Main Thread] WARNING: Theme parsing error: gtk.css:1:21: Failed to import: 開啟檔案 /home/hwhsu1231/snap/firefox/4033/.config/gtk-3.0/colors.css 時發生錯誤:No such file or directory: 'glib warning', file /build/firefox/parts/firefox/build/toolkit/xre/nsSigHandlers.cpp:187

(firefox:3713910): Gtk-WARNING **: 21:36:38.123: Theme parsing error: gtk.css:1:21: Failed to import: 開啟檔案 /home/hwhsu1231/snap/firefox/4033/.config/gtk-3.0/colors.css 時發生錯誤:No such file or directory
Gtk-Message: 21:36:38.157: Failed to load module "colorreload-gtk-module"
Gtk-Message: 21:36:38.157: Failed to load module "window-decorations-gtk-module"
ATTENTION: default value of option mesa_glthread overridden by environment.
ATTENTION: default value of option mesa_glthread overridden by environment.
^CExiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.
Exiting due to channel error.

(.venv) hwhsu1231@vb-kubuntu:~/Repo/testing/cmake-v3.28.4$ 
@n-peugnet
Copy link
Contributor

@hwhsu1231, do you observe the same behaviour as the one described in #12287? I.e. the parsed-literals can be translated but the translated content is incorrectly parsed.

If yes these are duplicates and we can close one of them.

@hwhsu1231
Copy link
Author

@n-peugnet Yes, I think they are duplicates.

Referring your demo in #12287, I test the bold (**text**) and italic (*text*) syntax in the parsed-literal of cmake.1.rst:

Click to expand the gettext po
#: ../../../manual/cmake.1.rst:11
msgid ""
"`Generate a Project Buildsystem`_\n"
" cmake [<options>] -B <path-to-build> [-S <path-to-source>]\n"
" cmake [<options>] <path-to-source | path-to-existing-build>\n"
"\n"
"`Build a Project`_\n"
" cmake --build <dir> [<options>] [-- <build-tool-options>]\n"
"\n"
"`Install a Project`_\n"
" cmake --install <dir> [<options>]\n"
"\n"
"`Open a Project`_\n"
" cmake --open <dir>\n"
"\n"
"`Run a Script`_\n"
" cmake [-D <var>=<value>]... -P <cmake-script-file>\n"
"\n"
"`Run a Command-Line Tool`_\n"
" cmake -E <command> [<options>]\n"
"\n"
"`Run the Find-Package Tool`_\n"
" cmake --find-package [<options>]\n"
"\n"
"`Run a Workflow Preset`_\n"
" cmake --workflow [<options>]\n"
"\n"
"`View Help`_\n"
" cmake --help[-<topic>]"
msgstr ""
"`Generate a Project Buildsystem`_\n"
" **cmake [<options>] -B <path-to-build> [-S <path-to-source>]**\n"
" *cmake [<options>] <path-to-source | path-to-existing-build>*\n"
"\n"
"`Build a Project`_\n"
" cmake --build <dir> [<options>] [-- <build-tool-options>]\n"
"\n"
"`Install a Project`_\n"
" cmake --install <dir> [<options>]\n"
"\n"
"`Open a Project`_\n"
" cmake --open <dir>\n"
"\n"
"`Run a Script`_\n"
" cmake [-D <var>=<value>]... -P <cmake-script-file>\n"
"\n"
"`Run a Command-Line Tool`_\n"
" cmake -E <command> [<options>]\n"
"\n"
"`Run the Find-Package Tool`_\n"
" cmake --find-package [<options>]\n"
"\n"
"`Run a Workflow Preset`_\n"
" cmake --workflow [<options>]\n"
"\n"
"`View Help`_\n"
" cmake --help[-<topic>]"

And the whole content is incorrectly parsed:

Screenshot_20240419_005516

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants