<!--
   $FML: discussion.sgml,v 1.2 2003/08/03 05:28:49 fukachan Exp $
   $jaFML: discussion.sgml,v 1.4 2003/04/15 14:51:42 fukachan Exp $
-->

<sect1>
	<title>
	Discussion: How To Send Back Language Dependent Error Mesages
	</title>

<para>
fml needs to send back language dependent error messages.
How we should implement it ?
</para>

<para>
(Below, just a discussion not implemation in fact.)
</para>


<!-- ===================================================== -->
<sect2>
	<title>
	&fml4; Case
	</title>

<para>
In the case of &fml4;, &fml4; calls language dependent message
converter like this:
<screen>
   Mesg(*e, KEYWORD, DEFAULT MESSAGE, ARGUMENT);
</screen>
</para>

<para>
Mesg() searches the specified keyword in files under
/usr/local/fml/messages/Japanese/ directory. Each file contains
messages with keywords to be substituted properly.
</para>

<para>
For example, the keyword not_found matches not_found entry in 
/usr/local/fml/messages/Japanese/kern file.
</para>

</sect2>



<!-- ===================================================== -->
<sect2>
	<title>
	What &fmldevel; Should Do ?
	</title>

<para>
"One file has one keyword" and "one file for one category, so one file
contains plural entries". Hmm, which is better? I don't determine it.
</para>

<sect3>
   <title>
    X/Open Portability Guide Issue 4 Version 2 (``XPG4.2'')
   </title>

<para>
If you use XPG (X/Open standard), 
<screen>
catgets(catd, set_id, msg_id, char *s);
</screen>
function converts the message specified by LOCALE_XXX.
	<footnote>
	<para>
	"s" is the default message.
	</para>
	</footnote>
For example, the usage is as follows:
<screen>
printf(catgets(catd, 30,  4,  "%s: Internal match error.\n"), progname);
</screen>
This function uses set 30 and entry 4 in the local definition file such
as /usr/pkg/share/nls/ja_JP.EUC/PROGNAME.cat.
</para>

</sect3>

<sect3>
   <title>
   &fmldevel;: Design (Temporary ?)
   </title>

<para>
One problem is whether we should use locale or not ?
In considering CUI e.g. makefml, it is better to use locale.
For example, prepare
<screen>
/usr/local/lib/fml/$fml_version/messages/ja_JP.EUC/kern

1: %s not found
2: %s (error number = %d)
</screen>
.
</para>

<para>
Instead, one file for one message may be useful.
Especially it is easy we can customize only one message.
</para>

<para>
To try the latter case, we can prepare a lot of classes such as
<screen>
FML::Message::ja::KEYWORD
</screen>
For example, there are 200 or 300 files such as
<screen>
FML::Message::ja::not_found
</screen>
.
</para>

<para>
This methods has the following problems:
<itemizedlist>
   <listitem>
	<para>
 	separete files but in contrast more customizable.
	</para>
   </listitem>

   <listitem>
	<para>
 	locale friendly? may be no.
	</para>
   </listitem>

</itemizedlist>
</para>


<para>
Consider an example. In the latter case, 
the message module will be like this?
<screen>
sub not_found
{
   my ..  = @_;

   return <<"_EOF_"
$sender is ... something ...
_EOF_
}
</screen>
Hmm, is it good ???
</para>

</sect3>


</sect2>

</sect1>
