[Ocaml-i18n] proposal: message catalogue system

Richard Jones rich at annexia.org
Sat Dec 6 07:09:04 PST 2003


On Sat, Dec 06, 2003 at 11:45:08AM +0000, Benjamin Geer wrote:
> Richard Jones wrote:
> >The trick (which we used on the aforementioned large Perl project) was
> >to have separate HTML templates for each language.
> 
> Suppose the page has to display a list of error messages.  Of course, it 
> doesn't know in advance what these will be.  Moreover, suppose these 
> same error messages need to be displayed in a short form on some pages, 
> and in a long form on other pages, depending on how much space the 
> graphic designer has.

I'm not quite sure if this is a real requirement of not. I know that
we did many 1000s of pages using the gettext approach and didn't come
across this sort of problem. Perhaps we were thinking of it
differently.

In particular, when we had needed to display a list of something, then
we would use the list feature of our templating library (which, BTW,
is extremely similar to the templating library included in
mod_caml). Thus:

<table>
 ::list(errors)::
  <tr><td> ::error_code:: </td> <td> ::error_message:: </td></tr>
 ::end::
</table>

(the ::list:: ... ::end:: feature generates multiple rows from an
array or list passed to the templating library by the program).

The list of error messages would be translated in the program, eg:

  @errors = ( { error_code => 500,
                error_message => gettext ("Internal Server Error") },
                error_code => 404,
                error_message => gettext ("Page Not Found") } );

At runtime the correct translation was chosen by gettext based on the
LANG environment variable, which was set on a request-by-request
basis, based on Accept: headers and the language preference for the
current user from the database.

I guess if you have short or long errors, then you can extend the
above easily enough so you also have a ::short_error_message:: field
which the graphic designer may substitute where necessary.

Rich.

-- 
Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj
Merjis Ltd. http://www.merjis.com/ - improving website return on investment
NET::FTPSERVER is a full-featured, secure, configurable, database-backed
FTP server written in Perl: http://www.annexia.org/freeware/netftpserver/



More information about the Ocaml-i18n mailing list