#1135662 man-db: Ordering of LANGUAGE (i.e. language priorities) ignored

Package:
man-db
Source:
man-db
Description:
tools for reading manual pages
Submitter:
Sascha Silbe
Date:
2026-05-04 11:45:02 UTC
Severity:
normal
Tags:
#1135662#5
Date:
2026-05-04 11:43:28 UTC
From:
To:
Dear Maintainer,

man-db uses the `LANGUAGE` environment variable in addition to the
locale to determine the man page search path. However, unlike gettext
(which is probably the authoritative documentation for the `LANGUAGE`
variable), it does not treat that variable as a search order / list of
priorities and simply sorts candidates lexically instead.

For example, if `LANGUAGE` is set to `fr:de`, it will show the German
man page instead of the French one (assuming both exist):

```
# Expected result: /usr/share/man/fr/man1/dpkg-architecture.1.gz
$ env -i LC_MESSAGES=en_US LANGUAGE=fr:de man -w dpkg-architecture
/usr/share/man/de/man1/dpkg-architecture.1.gz

# Matches expectations
$ env -i LC_MESSAGES=en_US LANGUAGE=fr man -w dpkg-architecture
/usr/share/man/fr/man1/dpkg-architecture.1.gz
```

Similarly, it seems to prefer the man pages matching `LC_MESSAGES`
(including from the non-locale directories when using an `en_*`
locale) even if it's not the first language in `LANGUAGE` (may be an
unusual combination but should still work):

```
# Expected result: /usr/share/man/fr/man1/dpkg-architecture.1.gz
$ env -i LC_MESSAGES=nl_NL LANGUAGE=fr:nl man -w dpkg-architecture
/usr/share/man/nl/man1/dpkg-architecture.1.gz

# Expected result: /usr/share/man/fr/man1/dpkg-architecture.1.gz
$ env -i LC_MESSAGES=nl_NL LANGUAGE=fr man -w dpkg-architecture
/usr/share/man/nl/man1/dpkg-architecture.1.gz

# Expected result: /usr/share/man/nl/man1/dpkg-architecture.1.gz
$ env -i LC_MESSAGES=fr_FR LANGUAGE=nl:fr man -w dpkg-architecture
/usr/share/man/fr/man1/dpkg-architecture.1.gz

# Expected result: /usr/share/man/nl/man1/dpkg-architecture.1.gz
$ env -i LC_MESSAGES=en_US LANGUAGE=nl:en man -w dpkg-architecture
/usr/share/man/man1/dpkg-architecture.1.gz
```


Not sure if this used to work (several Debian versions ago 😅) or if
it just got more noticeable over time because more man pages have
translations (installed by default) now.

I've left out the `--debug` versions of the above invocations as
they're rather verbose and are easy enough to reproduce on pretty much
any Debian system that has the `dpkg-dev` package installed.


Sascha