Question & Answer
Question
How Can I Display a Message Catalog File For a Program?
Answer
Example
NLSPATH environment variable
Conclusion
Introduction
Message catalogs are specially formatted files that contain text messages that can be displayed by a program. To facilitate translation of messages into various languages and locales, all messages displayed by a program are separated from the program's code and stored in message catalog files. When a program needs to display a message, the message is retrieved from the appropriate message catalog file and printed or displayed on the screen. At times it is useful to view all of the messages that can be displayed by a particular program. AIX provides the dspcat and dspmsg commands for viewing message catalog files. Message catalog files have the extension .cat and are stored in directories listed in the NLSPATH environment variable.
Example
In this example we will locate the English message catalog file for the ftpd daemon and display its contents.
- Which fileset supplies the ftpd
program?
# lslpp -w $(which ftpd)
bos.net.tcp.client
- Which fileset supplies the message catalog files for the ftpd program?
By convention, catalog files are stored in filesets that include .msg.<language> near the beginning of the fileset name. We can use the following command to search for the message fileset associated with the bos.net.tcp.client fileset:
# lslpp -L | grep "tcp.client"
bos.msg.en_US.net.tcp.client
bos.net.tcp.client 5.3.0.60 C F TCP/IP Client Support
- To view the actual catalog files included in the fileset
bos.msg.en_US.net.tcp.client, we can use the following command:
# lslpp -f bos.msg.en_US.net.tcp.client | grep ftpd
/usr/lib/nls/msg/en_US/ftpd.cat
/usr/lib/nls/msg/en_US/tftpdmsg.cat
- We can the dspcat
command to display all of the messages in the ftpd.cat message catalog file.
Consult the AIX man page for information on how to use the dspmsg command to display
single messages from the file.
# dspcat /usr/lib/nls/msg/en_US/ftpd.cat
1 : 1 Cannot get users ulimit.
1 : 2 getpeername (%s): %m
1 : 3 getsockname (%s): %m
1 : 4 ftpd: Bad value for -u
1 : 5 ftpd: Unknown flag -%c ignored.
1 : 6 signal: %m
1 : 7 setsockopt: %m
1 : 8 ioctl SIOCSPGRP: %m
1 : 9 %s FTP server (%s) ready.
1 : 10 lost connection
1 : 11 Local resource failure: malloc
1 : 12 Guest login ok, send ident as password.
1 : 13 Can't change user from guest login.
The dspcat and dspmsg commands will use the NLSPATH environment variable to locate catalog files if the full path to the catalog file is not included in the file name argument to the command. Application programs will also use the NLSPATH environment variable to find their message catalog files, so it is important that this variable is set properly. The NLSPATH environment variable contains a list of directories containing message catalog files. These directories are searched in the order in which they are listed in the contents of the variable. By default this variable is defined in /etc/environment with a value similar to the following:
NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
%L and %N are special system variables and are defined below:
- %L
This special variable identifies the locale specific directory that contains message catalog files. The value of the LC_MESSAGES category or the LANG environment variable is used for the directory name. The LANG, LC_ALL, or LC_MESSAGES environment variable can be set by the user to the locale for message catalogs. - %N
This special variable identifies the name of the catalog file.
Message catalog files contain the text messages that can be displayed by a program. These files are installed on a system with message catalog filesets. Sometimes it is useful for a system administrator to display the contents of a message catalog file to see all of the messages that can be displayed by a program. AIX provides the NLSPATH environment variable to specify where programs will search for the their message catalog files, and the commands dspcat and dspmsg for viewing the contents of message catalog files.
[{"Product":{"code":"SWG10","label":"AIX"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Support information","Platform":[{"code":"PF002","label":"AIX"}],"Version":"5.3;6.1;7.1","Edition":"","Line of Business":{"code":"LOB08","label":"Cognitive Systems"}}]
Was this topic helpful?
Document Information
Modified date:
17 June 2018
UID
isg3T1012017