To enable Chinese documentation for the man command on macOS, follow these steps to install and configure manpages-zh.
- Obtain the Source Code
Download the source from the official repository:
Extract the archive to a working directory.
- Install Build Dependencies
Use Homebrew to install required tools. If Homebrew isn’t installed, set it up first (preferably via a domestic mirror like Tsinghua’s if you’re in China):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Then install dependencies:
brew install autoconf automake python3 opencc groff
- Build and Install manpages-zh
Navigate to the extracted source directory and prepare the build system:
autoreconf --install --force
./configure --prefix=/usr/local/zhman --disable-zhtw
make
sudo make install
The --disable-zhtw flag ensures only Simplified Chinese is built.
- Configure the System to Use Chinese Man Pages
Edit the global man cnofiguration file. On macOS, this is typically /etc/man.conf (or create one if it doesn’t exist). Replace all instances of /usr/local/share/man with /usr/local/share/man/zh_CN, or add the Chinese path to the MANPATH section.
Add the following line at the end of /etc/man.conf to handle UTF-8 encoding proper:
NROFF preconv -e UTF8 | /usr/local/bin/nroff -Tutf8 -mandoc -c
This ensures correct rendering of Chinese characters by piping through preconv and using a UTF-8–capable nroff from the groff package installed earlier.
After configuration, test with:
man ls
If set up correctly, the manual page should appear in Simplified Chinese.