]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/nvi/catalog/README
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / nvi / catalog / README
1 #       $Id: README,v 9.0 2012/10/19 17:06:15 zy Exp $
2
3 Generally, all non-system error and informational messages in nvi are
4 catalog messages, i.e. they can be tailored to a specific langauge.
5 Command strings, usage strings, system errors and other 'known text'
6 are not.
7
8 Message catalogs in nvi are fairly simple.  Every catalog message
9 consists of two parts -- an initial number followed by a pipe (`|')
10 character, followed by the English text for the message.  For example:
11
12         msgq(sp, M_ERR, "001|This is an error message");
13
14 would be a typical message.
15
16 When the msgq() routine is called, if the user has specified a message
17 catalog and the format string (the third argument) has a leading number,
18 then it is converted to a record number, and that record is retrieved
19 from the message catalog and used as a replacement format string.  If
20 the record can't be retrieved for any reason, the English text is displayed
21 instead.
22
23 Each message format string MUST map into the English format string, i.e.
24 it can't display more or different arguments than the English one.
25
26 For example:
27
28         msgq(sp, M_ERR, "002|Error: %d %x", arg1, arg2);
29
30 is a format string that displays two arguments.
31
32 Arguments to the msgq function are required to contain ONLY printable
33 characters.  No further translation is done by the msgq routine before
34 displaying the message on the screen.  For example, in the msgq call:
35
36         msgq(sp, M_ERR, "003|File: %s", file_name);
37
38 "file_name" must contain only printable characters.  The routine
39 msg_print() returns a printable version of a string; the third argument
40 indicates whether the string needs to be freed.  For example:
41
42         char *p;
43         int nf;
44
45         p = msg_print(sp, file_name, &nf);
46         msgq(sp, M_ERR, "003|File: %s", p);
47         if (nf)
48                 FREE_SPACE(sp, p, 0);
49
50 makes sure that "file_name" is printable before calling the msgq
51 routine.
52
53 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
54
55 The message catalogs themselves are maintained in two files.  The first
56 is the "base file" which contains two fields, a record number and the
57 message itself.  All base files are named using the convention
58 "<language>.base", e.g. the English one is "english.base".  For
59 example:
60
61         002 "Line length overflow"
62         003 "unable to delete line %lu"
63         004 "unable to append to line %lu"
64         005 "unable to insert at line %lu"
65         006 "unable to store line %lu"
66         007 "unable to get last line"
67
68 are the first few lines of the current english.base file.
69
70 Before this file being converted to the second file, the POSIX formatted
71 message catalog file, by gencat(1), two lines:
72
73         $set 1
74         $quote "
75
76 will be inserted before the base text to setup the set_id and the quote
77 character.  So the double-quote needs to be escaped by a backslash to be
78 included in a message; same as the backslash itself.
79
80 These files are named for their language, e.g. "english".  However, a
81 locale(1) name is also recommended.
82
83 To create a new catalog for nvi:
84
85 Copy the file english.base to a file that you can modify , e.g.  "cp
86 english.base german.base".  For each of the messages in the file,
87 replace the message with the string that you want to use.  If you have
88 doubts about the meaning of a message, just email me.
89
90 A latest english.base can be created from source by running the command
91 "make english" in the catalog/ directory.
92
93 Once you've translated all of the strings, then add your catalog to the
94 "CAT=" line of the Makefile, and run the command "make catalog".  This
95 will create the second (and corresponding) file for each file named
96 <language>.base.
97
98 Don't worry about missing line numbers, i.e. base files that look like:
99
100         005     Message number 5.
101         007     Message number 7.
102
103 This simply means that a message was deleted during the course of nvi's
104 development.  It will be taken care of automatically when you create
105 the second form of the file.
106
107 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
108 If you add new messages to the nvi sources, you can check your work by
109 doing "make english; make check".  The "make check" target lists unused
110 message numbers, duplicate message numbers, and duplicate messages.
111 Unused message numbers are only useful if you are condensing messages.
112 Duplicate message numbers are a serious problem and have to be fixed.
113 Duplicate messages are only interesting if a message appears often enough
114 that it's worth creating a routine so that the string is only need in
115 a single place.
116
117 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
118 To select a catalog when running nvi, set the "msgcat" option.  If the
119 value of this option ends with a '/', it is treated as the name of a
120 directory that contains a message catalog "$LC_MESSAGES", which is set
121 through the LC_MESSAGES environment variable but returned by setlocale(3).
122 Check the output of locale(1) to validate such a value.  If the option
123 doesn't end in a '/', the option is treated as the full path name of the
124 message catalog to use.
125
126 If any messages are missing from the catalog, the backup text (English)
127 is used instead.