strmerge - batch string replacement
strmerge [-m prefix] [-p patternfile] [-s string] source-program...
Add prefix to message numbers in the output source program and source message catalog. You can use this prefix as a mnemonic. You must process source message catalogs that contain number prefixes using the mkcatdefs command. Message numbers will be in the form:
The strmerge command reads the strings specified in the message file produced by strextract and replaces those strings with calls to the message file in the source program to create a new source program. The new version of source program has the same name as the input source program, with the prefix nl_. For example, if the input source program is named prog.c, the output source program is named nl_prog.c. You use this command to replace hard-coded messages (text strings identified by the strextract command) with calls to the catgets function and to create a source message catalog file. The source message catalog contains the text for each message extracted from your input source program. The strmerge command names the file by appending .msg to the name of the input source program. For example, the source message catalog for the prog.c program is named prog.msg. You can use the source message catalog as input to the gencat command.
At run time, the program reads the message text from the message catalog. By storing messages in a message catalog, instead of your program, you allow the text of messages to be translated to a new language or modified without the source program being changed.
In the source-program argument, you name one or more source programs for which you want strings replaced. The strmerge command does not replace messages for source programs included using the #include directive. Therefore, you might want a source program and all the source programs it includes on a single strmerge command line.
You can create a patterns file (as specified by
) to control how the
text. The patterns file is divided into several sections, each of which is
identified by a keyword. The keyword must start at the beginning of a new
line, and its first character must be a dollar sign ($). Following the identifier,
you specify a number of patterns. Each pattern begins on a new line and follows
the regular expression syntax you use in the
For more information on the patterns file, see the
You can specify only one rewrite string for all classes of pattern matches.
The strmerge command does not verify if the message text file matches the source file being rewritten.
command does not replace strings to
files included with
directive. You must run the
command on these files separately.
The following produces a message file prog.cat for a program called prog.c.
% strextract -p c_patterns prog.c prog2.c % vi prog.str % strmerge -p c_patterns prog.c prog2.c % gencat prog.cat prog.msg prog2.msg % vi nl_prog.c % vi nl_prog2.c % cc nl_prog.c nl_prog2.c
In this example, the strextract command uses the c_patterns file to determine which strings to match. The input source programs are named prog.c and prog2.c.
If you need to remove any of the messages or extract one of the created strings, edit the resulting message file, prog.str. Under no conditions should you add to this file. Doing so could result in unpredictable behavior.
You issue the strmerge command to replace the extracted strings with calls to the message catalog. In response to this command, strmerge creates the source message catalogs, prog.msg and prog2.msg, and the output source programs, nl_prog.c and nl_prog2.c.
Before compiling the source programs, you must edit nl_prog.c and nl_prog2.c to include the appropriate catopen and catclose function calls.
command creates a message catalog and
command creates an executable program.
extract(1), gencat(1), strextract(1), trans(1), regexp(3), catopen(3), catgets(3), patterns(4)
Writing Software for the International Market