TeX-Live / texdoc

Find and view documentation in TeX Live
https://tug.org/texdoc/
GNU General Public License v3.0
47 stars 8 forks source link

How to automatically select the English language version of a documentation? #70

Closed samcarter closed 3 years ago

samcarter commented 3 years ago

If I run texdoc einfart I get the Chinese version of the documentation, despite

Why am I not getting the English version of the documentation? Am I missing some setting?

Here is the debug output:

texdoc debug-version: /usr/local/texlive/2021/texmf-dist/scripts/texdoc/texdoclib.tlu v3.3.1
texdoc debug-config: Setting "debug_list=all" from command line option "-D".
texdoc debug-config: Setting "lang=en" in file "/Users/username/.texmf/texdoc/texdoc.cnf" on line 2.
texdoc debug-config: Setting "suffix_list=doc, -doc, _doc, .doc, /doc, manual, /manual, -manual, userguide, /user_guide, -guide, -user, -man, notes, -info, ref" in file "/usr/local/texlive/2021/texmf-dist/texdoc/texdoc.cnf" on line 94.
texdoc debug-config: Setting "lastfile_switch=true" in file "/usr/local/texlive/2021/texmf-dist/texdoc/texdoc.cnf" on line 563.
texdoc debug-config: Ignoring "lang=en" from operating system locale.
texdoc debug-config: Setting "interact_switch=true" from built-in defaults.
texdoc debug-config: Setting "mode=view" from built-in defaults.
texdoc debug-config: Setting "badbasename_list=readme, 00readme" from built-in defaults.
texdoc debug-config: Setting "fuzzy_level=3" from built-in defaults.
texdoc debug-config: Setting "machine_switch=false" from built-in defaults.
texdoc debug-config: Setting "max_lines=20" from built-in defaults.
texdoc debug-config: Setting "basename_list=readme, 00readme" from built-in defaults.
texdoc debug-config: Setting "verbosity_level=2" from built-in defaults.
texdoc debug-config: Setting "badext_list=txt, dat, " from built-in defaults.
texdoc debug-config: Setting "ext_list=pdf, htm, html, txt, dat, md, ps, dvi, " from built-in defaults.
texdoc debug-config: Setting "rm_dir=rmdir" from built-in defaults.
texdoc debug-config: Setting "rm_file=rm -f" from built-in defaults.
texdoc debug-config: Setting "zipext_list=" from built-in defaults.
texdoc debug-files: Configuration file(s):
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-config/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-config/texdoc/texdoc.cnf
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-config/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-var/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-var/texdoc/texdoc.cnf
texdoc debug-files: not found   /Users/username/Library/texlive/2021/texmf-var/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /Users/username/.texmf/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: active  /Users/username/.texmf/texdoc/texdoc.cnf
texdoc debug-files: not found   /Users/username/.texmf/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /usr/local/texlive/texmf-local/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: not found   /usr/local/texlive/texmf-local/texdoc/texdoc.cnf
texdoc debug-files: not found   /usr/local/texlive/texmf-local/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-config/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-config/texdoc/texdoc.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-config/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-var/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-var/texdoc/texdoc.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-var/texdoc/texdoc-dist.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-dist/texdoc/texdoc-x86_64-darwinlegacy.cnf
texdoc debug-files: active  /usr/local/texlive/2021/texmf-dist/texdoc/texdoc.cnf
texdoc debug-files: not found   /usr/local/texlive/2021/texmf-dist/texdoc/texdoc-dist.cnf
texdoc debug-texdocs: texdocs[7] = /Users/username/Library/texlive/2021/texmf-config/doc (index_mandatory=false, recursion_allowed=true)
texdoc debug-texdocs: texdocs[6] = /Users/username/Library/texlive/2021/texmf-var/doc (index_mandatory=false, recursion_allowed=true)
texdoc debug-texdocs: texdocs[5] = /Users/username/.texmf/doc (index_mandatory=false, recursion_allowed=true)
texdoc debug-texdocs: texdocs[5] using index: /Users/username/.texmf (shift=doc/)
texdoc debug-texdocs: texdocs[4] = /usr/local/texlive/texmf-local/doc (index_mandatory=true, recursion_allowed=true)
texdoc debug-texdocs: texdocs[4] using index: /usr/local/texlive/texmf-local (shift=doc/)
texdoc debug-texdocs: texdocs[3] = /usr/local/texlive/2021/texmf-config/doc (index_mandatory=true, recursion_allowed=true)
texdoc debug-texdocs: texdocs[2] = /usr/local/texlive/2021/texmf-var/doc (index_mandatory=true, recursion_allowed=true)
texdoc debug-texdocs: texdocs[1] = /usr/local/texlive/2021/texmf-dist/doc (index_mandatory=true, recursion_allowed=true)
texdoc debug-texdocs: texdocs[1] using index: /usr/local/texlive/2021/texmf-dist (shift=doc/)
texdoc debug-tlpdb: Using cached data from /Users/username/Library/texlive/2021/texmf-var/texdoc/cache-tlpdb.lua
texdoc debug-search: Searching documents for pattern "einfart"
texdoc debug-search: File /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/LICENSE found.
texdoc debug-search: File /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/README.md found.
texdoc debug-search: File /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/einfart-doc-cn.pdf found.
texdoc debug-search: File /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/einfart-doc-en.pdf found.
texdoc debug-score: (b4ef41b) Start scoring /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/LICENSE
texdoc debug-score: (b4ef41b) Name used: latex/einfart/license
texdoc debug-score: (b4ef41b) Start heuristic scoring with pattern: einfart
texdoc debug-score: (b4ef41b) New heuristic score: 1.0. Reason: subword match
texdoc debug-score: (b4ef41b) New heuristic score: 0.1. Reason: bad extension
texdoc debug-score: (b4ef41b) New heuristic score: 1.6. Reason: directory bonus
texdoc debug-score: (b4ef41b) Final heuristic score: 1.6
texdoc debug-score: (b4ef41b) Max pattern score: 1.6
texdoc debug-score: (b4ef41b) Adjust by -10.0 from global pattern "license"
texdoc debug-score: (b4ef41b) Final score: -8.4
texdoc debug-score: (fd825a2) Start scoring /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/README.md
texdoc debug-score: (fd825a2) Name used: latex/einfart/readme.md
texdoc debug-score: (fd825a2) Start heuristic scoring with pattern: einfart
texdoc debug-score: (fd825a2) New heuristic score: 1.0. Reason: subword match
texdoc debug-score: (fd825a2) New heuristic score: 0.1. Reason: bad basename
texdoc debug-score: (fd825a2) New heuristic score: 1.6. Reason: directory bonus
texdoc debug-score: (fd825a2) Final heuristic score: 1.6
texdoc debug-score: (fd825a2) Max pattern score: 1.6
texdoc debug-score: (fd825a2) Catalogue "readme" bonus: +0.1
texdoc debug-score: (fd825a2) Adjust by 0.1 from global pattern "readme"
texdoc debug-score: (fd825a2) Final score: 1.8
texdoc debug-score: (0312650) Start scoring /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/einfart-doc-cn.pdf
texdoc debug-score: (0312650) Name used: latex/einfart/einfart-doc-cn.pdf
texdoc debug-score: (0312650) Start heuristic scoring with pattern: einfart
texdoc debug-score: (0312650) New heuristic score: 1.0. Reason: subword match
texdoc debug-score: (0312650) New heuristic score: 3.5. Reason: subword match for derived pattern: einfart-doc
texdoc debug-score: (0312650) New heuristic score: 5.0. Reason: directory bonus
texdoc debug-score: (0312650) Final heuristic score: 5.0
texdoc debug-score: (0312650) Max pattern score: 5.0
texdoc debug-score: (0312650) Catalogue details bonus: +1.5
texdoc debug-score: (0312650) Final score: 6.5
texdoc debug-score: (5f87cea) Start scoring /usr/local/texlive/2021/texmf-dist/doc/latex/einfart/einfart-doc-en.pdf
texdoc debug-score: (5f87cea) Name used: latex/einfart/einfart-doc-en.pdf
texdoc debug-score: (5f87cea) Start heuristic scoring with pattern: einfart
texdoc debug-score: (5f87cea) New heuristic score: 1.0. Reason: subword match
texdoc debug-score: (5f87cea) New heuristic score: 3.5. Reason: subword match for derived pattern: einfart-doc
texdoc debug-score: (5f87cea) New heuristic score: 5.0. Reason: directory bonus
texdoc debug-score: (5f87cea) Final heuristic score: 5.0
texdoc debug-score: (5f87cea) Max pattern score: 5.0
texdoc debug-score: (5f87cea) Catalogue details bonus: +1.5
texdoc debug-score: (5f87cea) Final score: 6.5
texdoc debug-config: Setting "viewer_dvi=open" from built-in defaults.
texdoc debug-config: Setting "viewer_html=open" from built-in defaults.
texdoc debug-config: Setting "viewer_txt=less" from built-in defaults.
texdoc debug-config: Setting "viewer_ps=open" from built-in defaults.
texdoc debug-config: Setting "viewer_pdf=open" from built-in defaults.
texdoc debug-view: Using "viewer_pdf" to open the file.
texdoc info: View command: open "/usr/local/texlive/2021/texmf-dist/doc/latex/einfart/einfart-doc-cn.pdf"
texdoc info: Setting environment LC_CTYPE to: en_US.UTF-8
wtsnjp commented 3 years ago

Why am I not getting the English version of the documentation? Am I missing some setting?

For a direct answer to your question, nothing is wrong with you, and nothing is wrong with Texdoc too. The reason why the English version does not win over the documentation in another language is that tlpkg catalog does not have the en metadata for einfart-doc-en.pdf (while einfart-doc-cn.pdf has its language metadata of zh). Thus, Texdoc does not recognize the document as an English version.

Screen_Shot_2021-07-07_at_10_32_34

You can ask TeX Live maintainers to add the en metadata for the catalog and that will solve this without any change in Texdoc, I guess. However, we can assume that basenames with the -en suffix are written in English, so our scoring mechanism can infer its language code. I will put this as a future enhancement.

kberry commented 3 years ago

Which documents in a package do or don't have metadata in the Catalogue is maintained by CTAN, not TeX Live. Write @.*** if you want a change there.

However, I completely agree with inferring that a "-en" document is English and think that would be a great enhancement. --best, karl.

samcarter commented 3 years ago

@wtsnjp Thank you very much for considering the enhancement about taking into account the suffix of the filename!