1b8ba871bSPeter Wemm# @(#)README 8.4 (Berkeley) 11/22/94 2b8ba871bSPeter Wemm 3b8ba871bSPeter WemmGenerally, all non-system error and informational messages in nvi are 4b8ba871bSPeter Wemmcatalog messages, i.e. they can be tailored to a specific langauge. 5b8ba871bSPeter WemmCommand strings, usage strings, system errors and other "known text" 6b8ba871bSPeter Wemmare not. It would certainly be possible to internationalize all the 7b8ba871bSPeter Wemmtext strings in nvi, but it's unclear that it's the right thing to do. 8b8ba871bSPeter Wemm 9b8ba871bSPeter WemmFirst, there's no portable way to do message catalogs. The System V 10b8ba871bSPeter Wemmscheme is a reasonable choice, but none of the 4BSD derived systems 11b8ba871bSPeter Wemmsupport it. So, catalogs are completely implemented within nvi, and 12b8ba871bSPeter Wemmdon't require any library support. 13b8ba871bSPeter Wemm 14b8ba871bSPeter WemmMessage catalogs in nvi are fairly simple. Every catalog message 15b8ba871bSPeter Wemmconsists of two parts -- an initial number followed by a pipe (`|') 16b8ba871bSPeter Wemmcharacter, followed by the English text for the message. For example: 17b8ba871bSPeter Wemm 18b8ba871bSPeter Wemm msgq(sp, M_ERR, "001|This is an error message"); 19b8ba871bSPeter Wemm 20b8ba871bSPeter Wemmwould be a typical message. 21b8ba871bSPeter Wemm 22b8ba871bSPeter WemmWhen the msgq() routine is called, if the user has specified a message 23b8ba871bSPeter Wemmcatalog and the format string (the third argument) has a leading number, 24b8ba871bSPeter Wemmthen it is converted to a record number, and that record is retrieved 25b8ba871bSPeter Wemmfrom the message catalog and used as a replacement format string. If 26b8ba871bSPeter Wemmthe record can't be retrieved for any reason, the English text is displayed 27b8ba871bSPeter Wemminstead. 28b8ba871bSPeter Wemm 29b8ba871bSPeter WemmEach message format string MUST map into the English format string, i.e. 30b8ba871bSPeter Wemmit can't display more or different arguments than the English one. 31b8ba871bSPeter Wemm 32b8ba871bSPeter WemmFor example: 33b8ba871bSPeter Wemm 34b8ba871bSPeter Wemm msgq(sp, M_ERR, "002|Error: %d %x", arg1, arg2); 35b8ba871bSPeter Wemm 36b8ba871bSPeter Wemmis a format string that displays two arguments. It is possible, however, 37b8ba871bSPeter Wemmto reorder the arguments or to not display all of them. The convention 38b8ba871bSPeter Wemmnvi uses is the System V printf(3) convention, i.e. "%[0-9]*$" is the name 39b8ba871bSPeter Wemmof a specific, numbered argument. For example: 40b8ba871bSPeter Wemm 41b8ba871bSPeter Wemm msgq(sp, M_ERR, "002|Error: %2$d %1$x", arg1, arg2); 42b8ba871bSPeter Wemm 43b8ba871bSPeter Wemmdisplays the arguments in reverse order. 44b8ba871bSPeter Wemm 45b8ba871bSPeter WemmIf the system supports this convention in its library printf routines 46b8ba871bSPeter Wemm(as specified by the test #define NL_ARGMAX), nvi uses those routines. 47b8ba871bSPeter WemmOtherwise, there is some serious magic going on in common/msg.c to make 48b8ba871bSPeter Wemmthis all work. 49b8ba871bSPeter Wemm 50b8ba871bSPeter WemmArguments to the msgq function are required to contain ONLY printable 51b8ba871bSPeter Wemmcharacters. No further translation is done by the msgq routine before 52b8ba871bSPeter Wemmdisplaying the message on the screen. For example, in the msgq call: 53b8ba871bSPeter Wemm 54b8ba871bSPeter Wemm msgq(sp, M_ERR, "003|File: %s", file_name); 55b8ba871bSPeter Wemm 56b8ba871bSPeter Wemm"file_name" must contain only printable characters. The routine 57b8ba871bSPeter Wemmmsg_print() returns a printable version of a string in allocated 58b8ba871bSPeter Wemmmemory. For example: 59b8ba871bSPeter Wemm 60b8ba871bSPeter Wemm char *p; 61b8ba871bSPeter Wemm 62b8ba871bSPeter Wemm p = msg_print(sp, file_name); 63b8ba871bSPeter Wemm msgq(sp, M_ERR, M("003", "File: %s"), p); 64b8ba871bSPeter Wemm FREE_SPACE(sp, p, 0); 65b8ba871bSPeter Wemm 66b8ba871bSPeter Wemmmakes sure that "file_name" is printable before calling the msgq 67b8ba871bSPeter Wemmroutine. 68b8ba871bSPeter Wemm 69b8ba871bSPeter Wemm=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 70b8ba871bSPeter Wemm 71b8ba871bSPeter WemmThe message catalogs themselves are maintained in two files. The first 72b8ba871bSPeter Wemmis the "base file" which contains two fields, a record number and the 73b8ba871bSPeter Wemmmessage itself. All base files are named using the convention 74b8ba871bSPeter Wemm"vi_<language>.base", e.g. the English one is "vi_english.base". For 75b8ba871bSPeter Wemmexample: 76b8ba871bSPeter Wemm 77b8ba871bSPeter Wemm 002 "Unable to create temporary file" 78b8ba871bSPeter Wemm 003 "Warning: %s is not a regular file" 79b8ba871bSPeter Wemm 004 "%s already locked, session is read-only" 80b8ba871bSPeter Wemm 005 "%s: remove" 81b8ba871bSPeter Wemm 006 "%s: close" 82b8ba871bSPeter Wemm 007 "%s: remove" 83b8ba871bSPeter Wemm 008 "%s: remove" 84b8ba871bSPeter Wemm 009 "Read-only file, not written; use ! to override" 85b8ba871bSPeter Wemm 010 "Read-only file, not written" 86b8ba871bSPeter Wemm 87b8ba871bSPeter Wemmare the first few lines of the current vi_english.base file. Note that 88b8ba871bSPeter Wemmmessage #1 is missing -- the first message of each catalog is a special 89b8ba871bSPeter Wemmone, so that nvi can recognize message catalog files. It's added by the 90b8ba871bSPeter WemmMakefile script that creates the second version of the message catalog. 91b8ba871bSPeter Wemm 92b8ba871bSPeter WemmThe second file is the file used by nvi to access messages, and is a list 93b8ba871bSPeter Wemmof the messages, one per line: 94b8ba871bSPeter Wemm 95b8ba871bSPeter Wemm VI_MESSAGE_CATALOG 96b8ba871bSPeter Wemm Unable to create temporary fileX 97b8ba871bSPeter Wemm Warning: %s is not a regular fileX 98b8ba871bSPeter Wemm %s already locked, session is read-onlyX 99b8ba871bSPeter Wemm %s: removeX 100b8ba871bSPeter Wemm %s: closeX 101b8ba871bSPeter Wemm %s: removeX 102b8ba871bSPeter Wemm %s: removeX 103b8ba871bSPeter Wemm Read-only file, not written; use ! to overrideX 104b8ba871bSPeter Wemm Read-only file, not writtenX 105b8ba871bSPeter Wemm 106b8ba871bSPeter WemmNote that all messages have had a trailing 'X' character appended. This 107b8ba871bSPeter Wemmis to provide nvi a place to store a trailing nul for the message so that 108b8ba871bSPeter WemmC library routines that expect one won't be disappointed. 109b8ba871bSPeter Wemm 110b8ba871bSPeter WemmThese files are named for their language, e.g. "vi_english". The second 111b8ba871bSPeter Wemmfiles are automatically created from the first files. 112b8ba871bSPeter Wemm 113b8ba871bSPeter WemmTo create a new catalog for nvi: 114b8ba871bSPeter Wemm 115b8ba871bSPeter WemmCopy the file vi_english.base to a file that you can modify , e.g. "cp 116b8ba871bSPeter Wemmvi_english.base vi_german.base". For each of the messages in the file, 117b8ba871bSPeter Wemmreplace the message with the string that you want to use. To find out 118b8ba871bSPeter Wemmwhat the arguments to a message are, I'm afraid you'll have to search 119b8ba871bSPeter Wemmthe source code for the message number. You can find them fairly quickly 120b8ba871bSPeter Wemmby doing: 121b8ba871bSPeter Wemm 122b8ba871bSPeter Wemm cd ..; egrep '123\|' */*.[chys] 123b8ba871bSPeter Wemm 124b8ba871bSPeter WemmI'm sorry that there's not an easier way, but I couldn't think of 125b8ba871bSPeter Wemmanything that wasn't a lot of work. 126b8ba871bSPeter Wemm 127b8ba871bSPeter WemmIf, for some reason, you don't have the file vi_english.base, or you 128b8ba871bSPeter Wemmhave new sources for which you want to create a new base catalog, you 129b8ba871bSPeter Wemmcan create it by running the command "make english" in the catalog 130b8ba871bSPeter Wemmdirectory. 131b8ba871bSPeter Wemm 132b8ba871bSPeter WemmOnce you've translated all of the strings, then add your catalog to the 133b8ba871bSPeter Wemm"CAT=" line of the Makefile, and run the command "make catalog". This 134b8ba871bSPeter Wemmwill create the second (and corresponding) file for each file named 135b8ba871bSPeter Wemm<language>.base. 136b8ba871bSPeter Wemm 137b8ba871bSPeter WemmDon't worry about missing line numbers, i.e. base files that look like: 138b8ba871bSPeter Wemm 139b8ba871bSPeter Wemm 005 Message number 5. 140b8ba871bSPeter Wemm 007 Message number 7. 141b8ba871bSPeter Wemm 142b8ba871bSPeter WemmThis simply means that a message was deleted during the course of nvi's 143b8ba871bSPeter Wemmdevelopment. It will be taken care of automatically when you create 144b8ba871bSPeter Wemmthe second form of the file. 145b8ba871bSPeter Wemm 146b8ba871bSPeter Wemm=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 147b8ba871bSPeter WemmIf you add new messages to the nvi sources, you can check your work by 148b8ba871bSPeter Wemmdoing "make english; make check". The "make check" target lists unused 149b8ba871bSPeter Wemmmessage numbers, duplicate message numbers, and duplicate messages. 150b8ba871bSPeter WemmUnused message numbers are only useful if you are condensing messages. 151b8ba871bSPeter WemmDuplicate message numbers are a serious problem and have to be fixed. 152b8ba871bSPeter WemmDuplicate messages are only interesting if a message appears often enough 153b8ba871bSPeter Wemmthat it's worth creating a routine so that the string is only need in 154b8ba871bSPeter Wemma single place. 155b8ba871bSPeter Wemm 156b8ba871bSPeter Wemm=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 157b8ba871bSPeter WemmTo select a catalog when running nvi, set the "msgcat" option. If the 158b8ba871bSPeter Wemmvalue of this option ends with a '/', it is treated as the name of a 159b8ba871bSPeter Wemmdirectory that contains a message catalog "vi_XXXX", where XXXX is the 160b8ba871bSPeter Wemmvalue of the LANG environmental variable, if it's set, or the value of 161b8ba871bSPeter Wemmthe LC_MESSAGES environmental variable if it's not. If neither of those 162b8ba871bSPeter Wemmenvironmental variables are set, or if the option doesn't end in a '/', 163b8ba871bSPeter Wemmthe option is treated as the full path name of the message catalog to use. 164b8ba871bSPeter Wemm 165b8ba871bSPeter WemmIf any messages are missing from the catalog, the backup text (English) 166b8ba871bSPeter Wemmis used instead. 167