less for viewing PO files ¶The ‘less’ program is a popular text file browser for use in a text screen or terminal emulator. It also supports text with embedded escape sequences for colors and text decorations.
You can use less to view a PO file like this (assuming an UTF-8
environment):
msgcat --to-code=UTF-8 --color xyz.po | less -R
You can simplify this to this simple command:
less xyz.po
after these three preparations:
LESS environment
variable. In sh shells:
$ LESS="$LESS -R -f" $ export LESS
LESSOPEN and
LESSCLOSE environment variables, as indicated in the manual page
(‘man less’).
msgcat on them, producing
a temporary file. Like this:
case "$1" in
*.po)
tmpfile=`mktemp "${TMPDIR-/tmp}/less.XXXXXX"`
msgcat --to-code=UTF-8 --color "$1" > "$tmpfile"
echo "$tmpfile"
exit 0
;;
esac