2

I have just found out that it is possible to display man pages in different laguages using the -L option (e.g. man -L fr man shows a man page in French). However, when a language is not available, an American English man page is usually shown. I do not prefer to read man pages in American English if one of my other languages is available.

How can I know what languages are available in advance?

It would be great if there is a command (e.g. man --list-languages cal) that outputs something like:

ar
de
en
my
zh
1

How about:

#!/usr/bin/env bash

if [ "$#" -eq 2 ]
then
    printf -v man_arg "%s %s" "$1" "$2"
elif [ "$#" -eq 1 ]
then
    printf -v man_arg "%s" "$1"
else
    printf "Wrong number of args\n" >&2
    exit 1
fi

LANG=C

mandir="$(dirname "$(dirname "$(man -w $man_arg)")")"
manfile="$(basename "$(man -w $man_arg)")"
part_to_rm="$(basename "$(dirname "$(man -w $man_arg)")")"

find "$mandir" -name "$manfile" | cut -d / -f4 | sed "/$part_to_rm/ d"

This script will display all languages that given manpage is available in besides English. Examples:

$ ./man-langs.sh cal
ja
$ ./man-langs.sh man
nl
pl
es
da
it
ja
de
zh_CN
ru
id
fr
$ ./man-langs.sh  xfce4-terminal
pl
es
sr
sv
da
pt
lt
it
ja
ar
gl
pt_BR
ca
el
de
ko
zh_CN
tr
ru
id
uk
ug
fr
$ ./man-langs.sh 1 printf
ja

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.