Assume that the file example.c contains two strings:
|
main()
{
printf("This is an example\n");
printf("Hello world!\n");
}
|
The exstr utility, invoked with the argument example.c extracts strings from the named file and prints them on the standard output.
produces the following output:
|
example.c:This is an example\n
example.c:Hello world!\n
|
The exstr utility, invoked with the -e option and the argument example.c, and redirecting output to the file example.stringsout
|
example% exstr -e example.c > example.stringsout
|
produces the following output in the file example.stringsout
|
example.c:3:8:::This is an example\n
example.c:4:8:::Hello world!\n
|
You must edit example.stringsout to add the values you want to use for the msgfile and msgnum fields before these strings can be replaced by calls to the retrieval function. If UX is the name of the message file, and the numbers 1 and 2 represent the sequence number of the strings in the file, here is what example.stringsout looks like after you
add this information:
|
example.c:3:8:UX:1:This is an example\n
example.c:4:8:UX:2:Hello world!\n
|
The exstr utility can now be invoked with the -r option to replace the strings in the source file by calls to the message retrieval function gettxt().
|
example% exstr -r example.c <example.stringsout >intlexample.c
|
produces the following output:
|
extern char *gettxt();
main()
{
printf(gettxt("UX:1", ""));
printf(gettxt("UX:2", ""));
}
|
The following example:
|
example% exstr -rd example.c <example.stringsout >intlexample.c
|
uses the extracted strings as a second argument to gettxt():
|
extern char *gettxt();
main()
{
printf(gettxt("UX:1", "This is an example\n"));
printf(gettxt("UX:2", "Hello world!\n"));
}
|
|