gettext: Customizing less

1 
1 9.11.5 Customizing ‘less’ for viewing PO files
1 ----------------------------------------------
1 
1    The ‘less’ program is a popular text file browser for use in a text
1 screen or terminal emulator.  It also supports text with embedded escape
1 sequences for colors and text decorations.
1 
1    You can use ‘less’ to view a PO file like this (assuming an UTF-8
1 environment):
1 
1      msgcat --to-code=UTF-8 --color xyz.po | less -R
1 
1    You can simplify this to this simple command:
1 
1      less xyz.po
1 
1 after these three preparations:
1 
1   1. Add the options ‘-R’ and ‘-f’ to the ‘LESS’ environment variable.
1      In sh shells:
1           $ LESS="$LESS -R -f"
1           $ export LESS
1 
1   2. If your system does not already have the ‘lessopen.sh’ and
1      ‘lessclose.sh’ scripts, create them and set the ‘LESSOPEN’ and
1      ‘LESSCLOSE’ environment variables, as indicated in the manual page
1      (‘man less’).
1 
1   3. Add to ‘lessopen.sh’ a piece of script that recognizes PO files
1      through their file extension and invokes ‘msgcat’ on them,
1      producing a temporary file.  Like this:
1 
1           case "$1" in
1             *.po)
1               tmpfile=`mktemp "${TMPDIR-/tmp}/less.XXXXXX"`
1               msgcat --to-code=UTF-8 --color "$1" > "$tmpfile"
1               echo "$tmpfile"
1               exit 0
1               ;;
1           esac
1