caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Jérôme Marant" <jerome.marant@fr.thalesgroup.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Printf and i18n
Date: Thu, 18 Apr 2002 10:02:42 +0200	[thread overview]
Message-ID: <20020418100241.B2735@fr.thalesgroup.com> (raw)
In-Reply-To: <20020418084753.A11351@verdot.inria.fr>; from daniel.de_rauglaudre@inria.fr on Thu, Apr 18, 2002 at 08:47:53AM +0200

On Thu, Apr 18, 2002 at 08:47:53AM +0200, Daniel de Rauglaudre wrote:
> 
> In my program GeneWeb, I use internationalization with printf. I have
> a function ftransl function defined like this (revised syntax):
> 
>   value ftransl lang (fmt : format 'a 'b 'c) : format 'a 'b 'c =
>      valid_format fmt (transl lang (Obj.magic fmt : string));
> 
> The function "transl", called inside this function, takes the language
> and the format fmt constrained to be a string and applies the translation.
> 
> The function "valid_format" checks that this resulting translation
> has the same % defined in the same order than fmt. Return the translated
> format if ok. If not ok, it returns the initial format, but you can
> fail, if you prefer.
> 
> 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: 

  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.

-- 
Jérôme 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


  parent reply	other threads:[~2002-04-18  8:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-17 17:37 Jérôme Marant
2002-04-17 17:53 ` [Caml-list] Modular subject-observer pattern ? Pascal Grossé
2002-04-18  6:47 ` [Caml-list] Printf and i18n Daniel de Rauglaudre
2002-04-18  8:01   ` John Prevost
2002-04-18  8:02   ` Jérôme Marant [this message]
2002-04-18  8:13     ` Jacques Garrigue
2002-04-18  8:17       ` Chris Hecker
2002-04-18  8:21       ` Jérôme Marant
2002-04-18  8:27     ` Daniel de Rauglaudre
2002-04-18  9:33       ` Jérôme Marant
2002-04-18 10:40         ` Daniel de Rauglaudre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020418100241.B2735@fr.thalesgroup.com \
    --to=jerome.marant@fr.thalesgroup.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).