From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA13103; Thu, 18 Apr 2002 10:03:06 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA13099 for ; Thu, 18 Apr 2002 10:03:05 +0200 (MET DST) Received: from gwsmtp.thomson-csf.com (gwsmtp.thomson-csf.com [195.101.39.226]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g3I835b13989 for ; Thu, 18 Apr 2002 10:03:05 +0200 (MET DST) Received: from thomplex.thomson-csf.com (200.3.2.2) by gwsmtp.thomson-csf.com (NPlex 5.1.053) id 3CBA667C0006F891 for caml-list@inria.fr; Thu, 18 Apr 2002 10:05:33 +0200 Received: from thomplex.thomson-csf.com (200.3.2.2) by thomplex.thomson-csf.com (NPlex 5.1.036) id 3CBA65C200078910 for caml-list@inria.fr; Thu, 18 Apr 2002 10:05:47 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CAC2CE100026458 for caml-list@inria.fr; Thu, 18 Apr 2002 10:02:42 +0200 Received: from bgxplex3.bgx.airsys.thomson-csf.com (1.38.9.153) by bgxplex3.bgx.airsys.thomson-csf.com (NPlex 5.1.053) id 3CAAD5C60001B2A2 for caml-list@inria.fr; Thu, 18 Apr 2002 10:13:56 +0200 Received: from 187.150.3.12 by bgxplex3.bgx.airsys.thomson-csf.com (InterScan E-Mail VirusWall NT); Thu, 18 Apr 2002 10:13:56 +0200 Received: from af_mara by lully.bgx.airsys.thomson-csf.com with local (Exim 3.22 #1 (Red Hat Linux)) id 16y6sM-0001Ft-00 for ; Thu, 18 Apr 2002 10:02:42 +0200 Date: Thu, 18 Apr 2002 10:02:42 +0200 From: =?iso-8859-1?Q?J=E9r=F4me_Marant?= To: caml-list@inria.fr Subject: Re: [Caml-list] Printf and i18n Message-ID: <20020418100241.B2735@fr.thalesgroup.com> Mail-Followup-To: caml-list@inria.fr References: <87ads2rzu8.fsf@marant.org> <20020418084753.A11351@verdot.inria.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20020418084753.A11351@verdot.inria.fr>; from daniel.de_rauglaudre@inria.fr on Thu, Apr 18, 2002 at 08:47:53AM +0200 Content-Transfer-Encoding: Quoted-Printable Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Thu, Apr 18, 2002 at 08:47:53AM +0200, Daniel de Rauglaudre wrote: >=20 > In my program GeneWeb, I use internationalization with printf. I have > a function ftransl function defined like this (revised syntax): >=20 > value ftransl lang (fmt : format 'a 'b 'c) : format 'a 'b 'c =3D > valid_format fmt (transl lang (Obj.magic fmt : string)); >=20 > The function "transl", called inside this function, takes the language > and the format fmt constrained to be a string and applies the translati= on. >=20 > The function "valid_format" checks that this resulting translation > has the same % defined in the same order than fmt. Return the translate= d > format if ok. If not ok, it returns the initial format, but you can > fail, if you prefer. >=20 > Therefore, instead of > printf "hello, my name is %s\n" name > you can write: > printf (ftransl "hello, y name is %s\n") name Thanks. That sounds what I'm looking for. By the way, in order to improve the localization process, we would need to add the "argument reordering" feature to printf functions. For instance, with:=20 printf " %2$d %1$s" "foo" 1 you get : 1 foo because some languages do not order words the same way. One more question : could you (or any other OCaml developer) give some explainations about the Obj module since, even "not for the casual user= ", it can be usefull sometimes (well at least for you and in the printf functions)? Thanks in advance. --=20 J=E9r=F4me Marant ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners