[Ocaml-i18n] locales in Camomile and OCamlI18n

Matthieu Sozeau mattam at altern.org
Sat May 22 05:32:14 PDT 2004


Hi,

On Saturday 22 May 2004 00:47, Benjamin Geer wrote:
> About OCamlI18n:
>
> Many locales use different characters for digits.  In Arabic, either
> Arabic or Hindi digits may be used.  So there needs to be a way for a
> locale-specific number formatter to choose the right kind of digits,
> according to the locale but also according to the user's preference;
> this of course applies to dates as well.
>
> I'm trying to understand how the 'calendar' structures are meant to be
> used; nothing in the library seems to use them.  If the goal is to make
> it possible for people to plug in their own calendar implementations,
> why not make Calendar a class type rather than a module?

I chose to have a module type (Calendar) and also a record type ('a calendar) 
to allow polymorphic programming on dates, but you're right in saying that a 
class type would be more appropriate. Calendars are used in Date formatting 
functions obviously, but, as you point out, the current design does not allow 
for other indications than the locale (you could still have 2 local variants 
for Arabic representing the different digits conventions). I just updated the 
documentation on my website to reflect the current code, which uses a functor 
from a format definition (which in turn is a functor of a calendar) and can 
be used like this:

module DateFormat = 
I18N.Format(I18N.DateFormatDefinition(I18N.Date.Gregorian))

let fmt = DateFormat.parse_format ~locale src_pattern in
	  DateFormat.parse ~locale fmt src 

The goal is to allow easy definition of formatters for particular calendars 
(and also for numbers, although code is currently commented in i18N.ml). 
Taking your example, we could have decimal and roman Number modules (or 
classes), with a format definition for decimals with different behavior for 
arabic and arabic_hindi.

Changing the design to object-style is needed for ldml anyway, so if you are 
interested in working on it, i'll be happy to discuss a rework of ocamli18n.
-- 
Do not underestimate the value of print statements for debugging.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
Url : /pipermail/ocaml-i18n/attachments/20040522/c11747f3/attachment.pgp 


More information about the Ocaml-i18n mailing list