Find file History
Latest commit d415f41 Nov 19, 2014 @bentley bentley committed with Use KNF in new code plus a few prototype fixes.
Closes #21
Permalink
..
Failed to load latest commit information.
Makefile Switch to gencat; quote " is enabled. Oct 19, 2012
README Document the new POSIX NLS based catalog policy. Oct 19, 2012
dump.c Use KNF in new code plus a few prototype fixes. Apr 3, 2015
dutch.base Escape the double-quotes within the messages. Oct 19, 2012
dutch.owner Same catalogs for nvi-17.9 & 1.8; require building. Jul 14, 2011
english.owner Same catalogs for nvi-17.9 & 1.8; require building. Jul 14, 2011
french.base Escape the double-quotes within the messages. Oct 19, 2012
german.base Escape the double-quotes within the messages. Oct 19, 2012
german.owner Same catalogs for nvi-17.9 & 1.8; require building. Jul 14, 2011
polish.base Escape the double-quotes within the messages. Oct 19, 2012
polish.owner Same catalogs for nvi-17.9 & 1.8; require building. Jul 14, 2011
ru_RU.KOI8-R.base Escape the double-quotes within the messages. Oct 19, 2012
ru_RU.KOI8-R.owner Finishes Russian translation by Pavel Timofeev. Aug 26, 2011
spanish.base Update the translations regarding ae3de76. Feb 10, 2012
swedish.base Escape the double-quotes within the messages. Oct 19, 2012
swedish.owner Same catalogs for nvi-17.9 & 1.8; require building. Jul 14, 2011
uk_UA.KOI8-U.base Escape the double-quotes within the messages. Oct 19, 2012
uk_UA.KOI8-U.owner Adds Ukrainian translation by Olexander Kunytsa. Aug 22, 2011
zh_CN.GB2312.base Escape the double-quotes within the messages. Oct 19, 2012
zh_CN.GB2312.owner Add myself as a catalog owner. Feb 15, 2012

README

#	$Id: README,v 9.0 2012/10/19 17:06:15 zy Exp $

Generally, all non-system error and informational messages in nvi are
catalog messages, i.e. they can be tailored to a specific langauge.
Command strings, usage strings, system errors and other 'known text'
are not.

Message catalogs in nvi are fairly simple.  Every catalog message
consists of two parts -- an initial number followed by a pipe (`|')
character, followed by the English text for the message.  For example:

	msgq(sp, M_ERR, "001|This is an error message");

would be a typical message.

When the msgq() routine is called, if the user has specified a message
catalog and the format string (the third argument) has a leading number,
then it is converted to a record number, and that record is retrieved
from the message catalog and used as a replacement format string.  If
the record can't be retrieved for any reason, the English text is displayed
instead.

Each message format string MUST map into the English format string, i.e.
it can't display more or different arguments than the English one.

For example:

	msgq(sp, M_ERR, "002|Error: %d %x", arg1, arg2);

is a format string that displays two arguments.

Arguments to the msgq function are required to contain ONLY printable
characters.  No further translation is done by the msgq routine before
displaying the message on the screen.  For example, in the msgq call:

	msgq(sp, M_ERR, "003|File: %s", file_name);

"file_name" must contain only printable characters.  The routine
msg_print() returns a printable version of a string; the third argument
indicates whether the string needs to be freed.  For example:

	char *p;
	int nf;

	p = msg_print(sp, file_name, &nf);
	msgq(sp, M_ERR, "003|File: %s", p);
	if (nf)
		FREE_SPACE(sp, p, 0);

makes sure that "file_name" is printable before calling the msgq
routine.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

The message catalogs themselves are maintained in two files.  The first
is the "base file" which contains two fields, a record number and the
message itself.  All base files are named using the convention
"<language>.base", e.g. the English one is "english.base".  For
example:

	002 "Line length overflow"
	003 "unable to delete line %lu"
	004 "unable to append to line %lu"
	005 "unable to insert at line %lu"
	006 "unable to store line %lu"
	007 "unable to get last line"

are the first few lines of the current english.base file.

Before this file being converted to the second file, the POSIX formatted
message catalog file, by gencat(1), two lines:

	$set 1
	$quote "

will be inserted before the base text to setup the set_id and the quote
character.  So the double-quote needs to be escaped by a backslash to be
included in a message; same as the backslash itself.

These files are named for their language, e.g. "english".  However, a
locale(1) name is also recommended.

To create a new catalog for nvi:

Copy the file english.base to a file that you can modify , e.g.  "cp
english.base german.base".  For each of the messages in the file,
replace the message with the string that you want to use.  If you have
doubts about the meaning of a message, just email me.

A latest english.base can be created from source by running the command
"make english" in the catalog/ directory.

Once you've translated all of the strings, then add your catalog to the
"CAT=" line of the Makefile, and run the command "make catalog".  This
will create the second (and corresponding) file for each file named
<language>.base.

Don't worry about missing line numbers, i.e. base files that look like:

	005	Message number 5.
	007	Message number 7.

This simply means that a message was deleted during the course of nvi's
development.  It will be taken care of automatically when you create
the second form of the file.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
If you add new messages to the nvi sources, you can check your work by
doing "make english; make check".  The "make check" target lists unused
message numbers, duplicate message numbers, and duplicate messages.
Unused message numbers are only useful if you are condensing messages.
Duplicate message numbers are a serious problem and have to be fixed.
Duplicate messages are only interesting if a message appears often enough
that it's worth creating a routine so that the string is only need in
a single place.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
To select a catalog when running nvi, set the "msgcat" option.  If the
value of this option ends with a '/', it is treated as the name of a
directory that contains a message catalog "$LC_MESSAGES", which is set
through the LC_MESSAGES environment variable but returned by setlocale(3).
Check the output of locale(1) to validate such a value.  If the option
doesn't end in a '/', the option is treated as the full path name of the
message catalog to use.

If any messages are missing from the catalog, the backup text (English)
is used instead.