[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
Hello Sylvain,

2006/1/23, Sylvain Le Gall <[EMAIL PROTECTED]>:
> For a GTK2 program, i recommend to use codeset = Some "UTF-8".

Ok. I'll fix that.

> Do you use "s_" and "f_" in your GTK2 interface ?

Partially, with a .glade file.

> If this the case, this functions should be evaluated after the parsing
> of the command line function (because before the language is not yet
> set).

Ok. I'll check but if I remember correctly, this is indeed the case currently.

> You are talking about a Glade interface, do you use a ".glade" file or
> do you use the translation of this glade file into OCaml ?

I'm using a .glade file, embedded in my application and loaded
transparently by Lablgtk.

> If you use a ".glade" file, use GettextStub.Native (because the
> translatable string stored in the file are translated using C gettext).

Ok, that explains my issue.

However, I'm also using "_s" functions. I suppose I have to define a
second module for those translations. How am I supposed to use both
modules? What should be the init sequence? (BTW, I would be nice to
put a word on this in your documentation)

> Working on it ;-)
> See
> http://www.gallu.homelinux.org/cgi-bin/viewcvs.cgi/ocaml-dbug/trunk/?rev=1006

Maybe I've not understood but this is apparently a logging library. I
was speaking more specifically of ocaml-gettext library debugging. But
maybe you plan to add this library as a depency to ocaml-gettext? In
that case, it would add another dependency to my own ones. :-( Anyway,
any help in debugging ocaml-gettext woud be useful.

> Please, send me a link/.tar.gz of your code, if you need help, i can
> maybe do something for you.

Here is the source code:
http://www.linux-france.org/~dmentre/demexp/latest-src/demexp--dev--0.7.tar.gz

The caml sources are made with noweb (nowebm debian package). They are
ending in .ml.nw.

The DemexpGettext module is defined in the lib/demexpGettext.ml.nw
file. It is used by gtk2-clnt/demexp-gtk2-client.ml.nw file. There is
also a call to an "_s" function in the latter source file. We plan to
add more calls soon. As usual, the translations are in the po/
directory.  Most part of the Makefile are in config/Makefile.inc.

I'll give another try to this issue soon. Thank you for the help.

Best wishes,
d.


___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Another issue with ocaml-gettext --action merge

2006-01-24 Par sujet David MENTRE
Hello Sylvain,

Yet another issue with your package! ;-)

When my makefile do:
$ ocaml-gettext --action merge --merge-pot po/demexp.pot po/fr.po

The fr.po file is mangled. 

The file is encoded in UTF-8. It's original content is:

#: gtk2-clnt/demexp_gladeui.glade:3762
msgid "As delegate"
msgstr "En tant que délégué"

After ocaml-gettext --action merge call, the file content is as follow:

#: gtk2-clnt/demexp_gladeui.glade:3762
msgid "As delegate"
msgstr "En tant que d\195\169l\195\169gu\195\169"


This mangling breaks all the translation:
  (demexp-gtk2-client:8131): Pango-WARNING **: Invalid UTF-8 string passed to 
pango_layout_set_text()


Is it related to Camomile bug you previously mentioned? Any idea how to
avoid this quite annoying behaviour?

My environment:
LANG=fr_FR.UTF-8
[EMAIL PROTECTED]


Best wishes,
d.
-- 
pub  1024D/A3AD7A2A 2004-10-03 David MENTRE <[EMAIL PROTECTED]>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
Hello Sylvain,

I'm making progress, but more issues appear. :-)

David MENTRE <[EMAIL PROTECTED]> writes:

> 2006/1/23, Sylvain Le Gall <[EMAIL PROTECTED]>:
>> For a GTK2 program, i recommend to use codeset = Some "UTF-8".
>
> Ok. I'll fix that.

done.

>> If you use a ".glade" file, use GettextStub.Native (because the
>> translatable string stored in the file are translated using C gettext).
>
> Ok, that explains my issue.

Ok, using GettextStub.Native the translation works!

Here is my definition of my program's Gettext module:

module Gettext = Gettext.Program
(struct
  let textdomain   = "demexp"
  let codeset  = Some "UTF-8"
  let dir  = None
  let dependencies = Gettext.init
end)
(GettextStub.Native)

The .glade translation works when calling my program with:
 $ echo $LANG
 fr_FR.UTF-8

 $ ./gtk2-clnt/demexp-gtk2-client --gettext-dir build/share/locale/po/ 

A question: why do I need to give the final po/ directory? I though that
I should give "build/share/locale/", as the default for gettext-dir is
["/usr/share/locale"; "/usr/local/share/locale"].



But now working translation raises another issue: call to printf are
modified!!

For example, if at the end of a module I put:
  let _ = Printf.printf "1.0 = %3.3f\n" 1.0

I get as result when launching above program:
  1.0 = 1,000

It is obvious that the locale is taken into account for printing the
string. But this seems quite strange to me, as I do not use an _s
function in this call to printf.

This behaviour is a issue to me because:

 - I want to control when a sentence is interpreted as translatable or
   not;

 - I'm having autotest where I check hard-coded results for certain
   function calls. This behaviour breaks them.



> However, I'm also using "_s" functions. I suppose I have to define a
> second module for those translations. How am I supposed to use both
> modules? What should be the init sequence? (BTW, I would be nice to
> put a word on this in your documentation)

Ok, it seems that call to "f_" and the like are working with
GettextStub.Native, so I don't need to use simultaneously
GettextStub.Native and GettextCamomile.Map.

Is it an issue to use GettextStub.Native?


Best wishes,
d.
-- 
pub  1024D/A3AD7A2A 2004-10-03 David MENTRE <[EMAIL PROTECTED]>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
Hello,

"Sylvain Le Gall" <[EMAIL PROTECTED]> writes:

>> Yes, using LANG=C when calling my program solves the issue. But for my
>> autotests, I need to do that *from* the program. Do you see a way to set
>> the locale from OCaml, for a given part of the code?
>> 
>
> Humm, there is a way, but it is C code and it is not really clean:
>
> /* Change language.  */
> setenv ("LANGUAGE", "fr", 1);
>
> /* Make change known.  */
> {
>   extern int  _nl_msg_cat_cntr;
>   ++_nl_msg_cat_cntr;
> }
>
> (from the gettext manual:
> http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC155
> )

Well, you're right, it isn't very clean. :) As I have found a
work-around my issue (see me other email), I'll keep it that way and
keep this solution in the archive if I ever have another issue that
needs this kind of work-around.


> Well, the avantage of camomile is that you can produce full ocaml native
> application (almost without C binding). The only other advantage, is not
> really "external developper" visible: it is a little bit cleaner because
> you have better control of thread unsafe variable. But it is not an
> issue, both implementation should work well.

Thank you for the explanation. Anyway, as I'm using the .glade system,
I'm forced to use GettextStub.Native.

One issue solved. :) Thanks!

Best wishes,
d.
-- 
pub  1024D/A3AD7A2A 2004-10-03 David MENTRE <[EMAIL PROTECTED]>
 5996 CC46 4612 9CA4 3562  D7AC 6C67 9E96 A3AD 7A2A



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
"Sylvain Le Gall" <[EMAIL PROTECTED]> writes:

> I don't see any "s_" or "f_" in you code. Do you have any translatable
> string in your code ?

There is one, see:
<>=
let connect_to_server pref user_msg =
  let timer = Perf.timer_start () in
  user_msg (Printf.sprintf (f_ "Connecting to server %s:%d...")
^^^ 


But as I said in a previous message, it seems to work. I added a simple
Printf.printf (f_ "Cancel") and it was successfully printed as
"Annuler".

Best wishes,
d.
-- 
 [EMAIL PROTECTED]



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
David MENTRE <[EMAIL PROTECTED]> writes:

> Yes, using LANG=C when calling my program solves the issue. But for my
> autotests, I need to do that *from* the program. Do you see a way to set
> the locale from OCaml, for a given part of the code?

Ok, I've found a work around, calling Printf.sprintf to generate the
result test. It is probably less clear than before but works across any
locale.

For those following demexp development, I've applied following patch:
-assert(time_as_string 0.1 = "1.000 ns"); 
-assert(time_as_string 0.01 = "1.000 us"); 
-assert(time_as_string 0.001 = "1.000 ms"); 
-assert(time_as_string 1. = "1.000 s"); 
+assert(time_as_string 0.1 = Printf.sprintf "%.3f ns" 1.0);
+assert(time_as_string 0.01 = Printf.sprintf "%.3f us" 1.0);
+assert(time_as_string 0.001 = Printf.sprintf "%.3f ms" 1.0);
+assert(time_as_string 1. = Printf.sprintf "%.3f s" 1.0);


Best wishes,
d.
-- 
 [EMAIL PROTECTED]



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] [Sylvain Le Gall] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
Answer of Sylvain.

d.

--- Begin Message ---
Hello,

On Tue, Jan 24, 2006 at 07:52:16PM +0100, David MENTRE wrote:
> Hello Sylvain,
> 
> I'm making progress, but more issues appear. :-)
> 
> David MENTRE <[EMAIL PROTECTED]> writes:
> 
> > 2006/1/23, Sylvain Le Gall <[EMAIL PROTECTED]>:
> >> For a GTK2 program, i recommend to use codeset = Some "UTF-8".
> >
> > Ok. I'll fix that.
> 
> done.
> 
> >> If you use a ".glade" file, use GettextStub.Native (because the
> >> translatable string stored in the file are translated using C gettext).
> >
> > Ok, that explains my issue.
> 
> Ok, using GettextStub.Native the translation works!
>

Great ! (at least my work is not a piece of crap ;-) ).

> Here is my definition of my program's Gettext module:
> 
> module Gettext = Gettext.Program
> (struct
>   let textdomain   = "demexp"
>   let codeset  = Some "UTF-8"
>   let dir  = None
>   let dependencies = Gettext.init
> end)
> (GettextStub.Native)
> 
> The .glade translation works when calling my program with:
>  $ echo $LANG
>  fr_FR.UTF-8
> 
>  $ ./gtk2-clnt/demexp-gtk2-client --gettext-dir build/share/locale/po/ 
> 
> A question: why do I need to give the final po/ directory? I though that
> I should give "build/share/locale/", as the default for gettext-dir is
> ["/usr/share/locale"; "/usr/local/share/locale"].
> 
> 

I will take a look at that.

> 
> But now working translation raises another issue: call to printf are
> modified!!
> 
> For example, if at the end of a module I put:
>   let _ = Printf.printf "1.0 = %3.3f\n" 1.0
> 
> I get as result when launching above program:
>   1.0 = 1,000
> 
> It is obvious that the locale is taken into account for printing the
> string. But this seems quite strange to me, as I do not use an _s
> function in this call to printf.
> 
> This behaviour is a issue to me because:
> 
>  - I want to control when a sentence is interpreted as translatable or
>not;
> 
>  - I'm having autotest where I check hard-coded results for certain
>function calls. This behaviour breaks them.
> 
> 

Humm, i think that a C printf call is used in the Printf module, which
take into account that locale you have set using LANG.

Maybe, you should try something like "env LC_NUMERIC=C myprogram" which
should give you the expected result (if C is bind to english, otherwise
try LC_NUMERIC=en_US).

> 
> > However, I'm also using "_s" functions. I suppose I have to define a
> > second module for those translations. How am I supposed to use both
> > modules? What should be the init sequence? (BTW, I would be nice to
> > put a word on this in your documentation)
> 
> Ok, it seems that call to "f_" and the like are working with
> GettextStub.Native, so I don't need to use simultaneously
> GettextStub.Native and GettextCamomile.Map.
> 
> Is it an issue to use GettextStub.Native?
> 

What are _s functions ? Why should it be an issue to use
GettextStub.Native ?

> 
> Best wishes,
> d.

Kind regard
Sylvain Le Gall

--- End Message ---


-- 
 [EMAIL PROTECTED]
___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev


[Demexp-dev] Re: Issue to use ocaml-gettext with lablgtk

2006-01-24 Par sujet David MENTRE
Sylvain,

[ Could you keep demexp-dev in the Cc:? It allows archiving of emails
  for future people having same issue as me. ]

"Sylvain Le Gall" <[EMAIL PROTECTED]> writes:

>> For example, if at the end of a module I put:
>>   let _ = Printf.printf "1.0 = %3.3f\n" 1.0
>> 
>> I get as result when launching above program:
>>   1.0 = 1,000
>
> Humm, i think that a C printf call is used in the Printf module, which
> take into account that locale you have set using LANG.

Hmmm, I'm quite suprised that Printf is using C printf. But I checked in
3.08.2 source code and you are indeed right: Printf.scan_format is
calling external format_float which has a call to C sprintf.

> Maybe, you should try something like "env LC_NUMERIC=C myprogram" which
> should give you the expected result (if C is bind to english, otherwise
> try LC_NUMERIC=en_US).

Yes, using LANG=C when calling my program solves the issue. But for my
autotests, I need to do that *from* the program. Do you see a way to set
the locale from OCaml, for a given part of the code?

>> > However, I'm also using "_s" functions. I suppose I have to define a
>> > second module for those translations. How am I supposed to use both
>> > modules? What should be the init sequence? (BTW, I would be nice to
>> > put a word on this in your documentation)
>> 
>> Ok, it seems that call to "f_" and the like are working with
>> GettextStub.Native, so I don't need to use simultaneously
>> GettextStub.Native and GettextCamomile.Map.
>> 
>> Is it an issue to use GettextStub.Native?
>> 
>
> What are _s functions ?

Sorry, I was confused, I meant s_, f_ & Co. functions.

> Why should it be an issue to use GettextStub.Native ?

I don't know. :) I suppose that, as you have made gettext through
Camomile available, there are some advantages to use it over the stub
version?

Best wishes,
d.
-- 
 [EMAIL PROTECTED]



___
Demexp-dev mailing list
Demexp-dev@nongnu.org
http://lists.nongnu.org/mailman/listinfo/demexp-dev