git: 5250c9890848 - main - usr.bin/man: allow man(1) to search translated manpages in pure $man_lang subdirectory (+)

From: Dima Panov <fluffy_at_FreeBSD.org>
Date: Mon, 26 Oct 2026 20:23:19 UTC
The branch main has been updated by fluffy:

URL: https://cgit.FreeBSD.org/src/commit/?id=5250c98908482babae8379b4dede10c64e8639ae

commit 5250c98908482babae8379b4dede10c64e8639ae
Author:     Dima Panov <fluffy@FreeBSD.org>
AuthorDate: 2026-10-26 20:07:56 +0000
Commit:     Dima Panov <fluffy@FreeBSD.org>
CommitDate: 2026-10-26 20:07:56 +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
---
 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 18b58f3c03b3..fbe820c99592 100644
--- a/usr.bin/man/man.1
+++ b/usr.bin/man/man.1
@@ -223,6 +223,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
@@ -240,6 +242,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 d6429901c598..9d54ed67bd2f 100755
--- a/usr.bin/man/man.sh
+++ b/usr.bin/man/man.sh
@@ -747,7 +747,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