git: 33c8b4b3f869 - stable/14 - usr.bin/man: allow man(1) to search translated manpages in pure $man_lang subdirectory (+)

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Tue, 27 Oct 2026 22:07:07 UTC
The branch stable/14 has been updated by fluffy:

URL: https://cgit.FreeBSD.org/src/commit/?id=33c8b4b3f8699772c6bb9def696a2c9da670af99

commit 33c8b4b3f8699772c6bb9def696a2c9da670af99
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2026-10-26 20:07:56 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2026-10-27 22:06:59 +0000

    usr.bin/man: allow man(1) to search translated manpages in pure $man_lang subdirectory (+)
    
    Currently our man(1) utility search manages only in $lang_country.$charset, $lang.$charset and,
    as failover, in en.$charset which is historical behavior.
    But nowadays most of ported software uses only $lang subdirectories for translated manpages
    instead of use full locale notation, for example, share/ja/man1, share/de/man1, share/ru/man1.
    In such cases, our man(1) utility cannot find any translated manpages and silently fallback to english version.
    
    Add $man_lang in search path allows man(1) search and use translated manpages under historical and modern path traditions
    
    MFC after:              1 day
    MFC to:                 stable/15 stable/14
    Reviewed by:            ziaee, fernape
    Approved by:            fernape
    Differential Revision:  https://reviews.freebsd.org/D55805
    
    (cherry picked from commit 5250c98908482babae8379b4dede10c64e8639ae)
---
 usr.bin/man/man.1  | 4 ++++
 usr.bin/man/man.sh | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1
index 707677ccce06..43c1d4c15056 100644
--- a/usr.bin/man/man.1
+++ b/usr.bin/man/man.1
@@ -225,6 +225,8 @@ will search for locale specific manual pages using the following logic:
 .It
 .Va lang . Ns Va charset
 .It
+.Va lang
+.It
 .Li en . Ns Va charset
 .El
 .Pp
@@ -242,6 +244,8 @@ will search the following paths when considering section 1 manual pages in
 .It
 .Pa /usr/share/man/ja.eucJP/man1
 .It
+.Pa /usr/share/man/ja/man1
+.It
 .Pa /usr/share/man/en.eucJP/man1
 .It
 .Pa /usr/share/man/man1
diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh
index 8c734a4c47a1..853fc918facb 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -733,7 +733,7 @@ man_setup_locale() {
 				man_country="${lang_cc#*_}"
 				man_charset="${locstr#*.}"
 				locpaths="$locstr"
-				locpaths="$locpaths:$man_lang.$man_charset"
+				locpaths="$locpaths:$man_lang.$man_charset:$man_lang"
 				if [ "$man_lang" != "en" ]; then
 					locpaths="$locpaths:en.$man_charset"
 				fi