Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

8 messages Options
Embed this post
Permalink
HamishB

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
Maris Nartiss wrote:
> last night I was cleaning up GRASS translation and found GRASS error
> messages very inconsistent.

In the past when adding i18n macros to modules I have used this method:

#search for messages already in use:
grass-src$ cd raster
raster$ grep -rI -A5 G_find_cell2 * | grep fatal

this gives a list of messages already used for that function (here
G_find_cell2()), then I just reuse the nicest message from that list
(prefer "raster map" to "cell file", <%s> brackets around map names,
square brackets around values (invalid color [%s]), etc).

A centralized list would be a nice idea, but I would modify Brad's macro
names,

-MSG_*
+ERR_MSG_*
+WRN_MSG_*

(and formalize usage of <> vs [], etc)

Brad:
> Okay, we now have a standard set of messages, but now locale macros
> need to be dealt with.  There's a few ways to deal with it, but none
> of them seem trivial to me.

#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
#define ERRMSG_RASTER_OPEN_FILE_MAPSET _("Unable to find raster map <%s@%s>")
#define ERRMSG_RASTER_WRITE_FILE       _("Unable to write to raster map <%s>")
...

?
but these should probably live in a .h file, and would #include <glocale.h>
at the top of that enough to get them translated at run time? (I assume not?)


Hamish

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations
HamishB

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
Maris Nartiss wrote:
> last night I was cleaning up GRASS translation and found GRASS error
> messages very inconsistent.

another point re. rationalized error messages. Sometimes a module uses
the same fn call for two different maps, and the error messages are
slightly different (e.g. "<%s> base map not found" and "<%s> cover map
not found"). In that case it is best to keep the existing (cleaned)
error messages. Similar to the use of G_define_option() versus
G_define_standard_option().

[but slightly different, with G_define_standard_option() you can follow
it with e.g. a single change, e.g. opt->description="text"]


Hamish

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations
Jáchym Čepický-2

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
In reply to this post by HamishB
hallo,

I greped-out list of "not found" messages used in grass raster modules

grep -r -i "not found" */*.c |grep \"| sed "s/.*\"\(.*\)\".*/\1/g"

Basicly, there are following slightly different messages:

messages with mostly with G_program_name(), some_map->answer
-----------------------------------------------------------
    %s: %s - raster map not found
    %s: <%s> raster file not found
    cell file [%s] not found
    vector map <%s> not found
    %s: <%s> not found
    %s: <%s> reference map not found
    %s: <%s> cellfile not found
    ...

messages with only some_map->answer
-----------------------------------
    %s - map not found
    %s - map not found
    <%s> raster file not found
    Input file [%s] not found.
    File not found: %s
    Terrain raster map <%s> not found!
    Raster map [%s] not found
    %s: base raster map not found
    %s: cover raster map not found
    Raster map or group [%s] not found
    Cell file [%s] not found\n
    Raster map [%s] not found
    ...

messages with special meaing of raster/vector map
-------------------------------------------------
    3dview file <%s> not found
    Old 3dview file. Region not found in <%s> in <%s>
    elevin cell file <%s> not found
    aspin cell file <%s> not found
    slopein cell file <%s> not found
    linkein cell file <%s> not found
    albedo cell file <%s> not found
    latin cell file <%s> not found
    coefbh cell file <%s> not found
    coefdh cell file <%s> not found
    Raster file [%s] not found
    contour cell file [%s] not found\n
    ...

My suggestion is:

Index: include/glocale.h
===================================================================
RCS file: /grassrepository/grass6/include/glocale.h,v
retrieving revision 2.2
diff -u -r2.2 glocale.h
--- include/glocale.h   26 Nov 2006 21:32:36 -0000      2.2
+++ include/glocale.h   13 Dec 2006 18:51:56 -0000
@@ -1,6 +1,11 @@
 #ifndef GRASS_GLOCALE_H
 #define GRASS_GLOCALE_H
 
+#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
+#define ERRMSG_VECTOR_OPEN_FILE        _("Unable to find vector map <%s>")
+#define ERRMSG_ASCII_OPEN_FILE        _("Unable to find ASCII file <%s>")
+#define ERRMSG_OTHER_OPEN_FILE        _("Unable to find file <%s>")
+
 #include <grass/config.h>
 
 extern char * G_gettext(const char *, const char *);
@@ -11,6 +16,7 @@
 #else
 #define _(str) (str)
 #endif
+
 
 #endif
 
There could come other messages during the time, but this four ERRMSG could cover all
"not found" messages listed above.

What do you think?

Thanks

Jachym

On Mon, Dec 11, 2006 at 04:41:26PM +1300, Hamish wrote:

> Maris Nartiss wrote:
> > last night I was cleaning up GRASS translation and found GRASS error
> > messages very inconsistent.
>
> In the past when adding i18n macros to modules I have used this method:
>
> #search for messages already in use:
> grass-src$ cd raster
> raster$ grep -rI -A5 G_find_cell2 * | grep fatal
>
> this gives a list of messages already used for that function (here
> G_find_cell2()), then I just reuse the nicest message from that list
> (prefer "raster map" to "cell file", <%s> brackets around map names,
> square brackets around values (invalid color [%s]), etc).
>
> A centralized list would be a nice idea, but I would modify Brad's macro
> names,
>
> -MSG_*
> +ERR_MSG_*
> +WRN_MSG_*
>
> (and formalize usage of <> vs [], etc)
>
> Brad:
> > Okay, we now have a standard set of messages, but now locale macros
> > need to be dealt with.  There's a few ways to deal with it, but none
> > of them seem trivial to me.
>
> #define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
> #define ERRMSG_RASTER_OPEN_FILE_MAPSET _("Unable to find raster map <%s@%s>")
> #define ERRMSG_RASTER_WRITE_FILE       _("Unable to write to raster map <%s>")
> ...
>
> ?
> but these should probably live in a .h file, and would #include <glocale.h>
> at the top of that enough to get them translated at run time? (I assume not?)
>
>
> Hamish
>
> _______________________________________________
> grass-dev mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: [hidden email]
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------  
OFFICE:                                    
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: [hidden email]
URL:    http://mapserver.mendelu.cz
Tel.:   +420 545 134 514


_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations

signature.asc (196 bytes) Download Attachment
Brad Douglas

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
In reply to this post by HamishB
On Mon, 2006-12-11 at 16:41 +1300, Hamish wrote:

> Maris Nartiss wrote:
> > last night I was cleaning up GRASS translation and found GRASS error
> > messages very inconsistent.
>
> In the past when adding i18n macros to modules I have used this method:
>
> #search for messages already in use:
> grass-src$ cd raster
> raster$ grep -rI -A5 G_find_cell2 * | grep fatal
>
> this gives a list of messages already used for that function (here
> G_find_cell2()), then I just reuse the nicest message from that list
> (prefer "raster map" to "cell file", <%s> brackets around map names,
> square brackets around values (invalid color [%s]), etc).
>
> A centralized list would be a nice idea, but I would modify Brad's macro
> names,
>
> -MSG_*
> +ERR_MSG_*
> +WRN_MSG_*
>
> (and formalize usage of <> vs [], etc)
>
> Brad:
> > Okay, we now have a standard set of messages, but now locale macros
> > need to be dealt with.  There's a few ways to deal with it, but none
> > of them seem trivial to me.
>
> #define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
> #define ERRMSG_RASTER_OPEN_FILE_MAPSET _("Unable to find raster map <%s@%s>")
> #define ERRMSG_RASTER_WRITE_FILE       _("Unable to write to raster map <%s>")
> ...
>
> ?
> but these should probably live in a .h file, and would #include <glocale.h>
> at the top of that enough to get them translated at run time? (I assume not?)

What I meant by "not exactly trivial" is that the above will *require*
locale support.  Two conditional copies of the same thing to accommodate
with and without locale is ugly...even worse is definitions in two
separate files (glocale.h and another non-locale header).

I have no elegant answer.


--
Brad Douglas <rez touchofmadness com>                    KB8UYR/6
Address: 37.493,-121.924 / WGS84    National Map Corps #TNMC-3785

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations
HamishB

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
In reply to this post by Jáchym Čepický-2
Jachym Cepicky wrote:

> My suggestion is:
>
> Index: include/glocale.h
> ===================================================================
> RCS file: /grassrepository/grass6/include/glocale.h,v
> retrieving revision 2.2
> diff -u -r2.2 glocale.h
> --- include/glocale.h   26 Nov 2006 21:32:36 -0000      2.2
> +++ include/glocale.h   13 Dec 2006 18:51:56 -0000
> @@ -1,6 +1,11 @@
>  #ifndef GRASS_GLOCALE_H
>  #define GRASS_GLOCALE_H
>
> +#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
> +#define ERRMSG_VECTOR_OPEN_FILE        _("Unable to find vector map <%s>")
> +#define ERRMSG_ASCII_OPEN_FILE        _("Unable to find ASCII file <%s>")
> +#define ERRMSG_OTHER_OPEN_FILE        _("Unable to find file <%s>")


Will that hardcode whatever language GRASS was built with as the
only translation it can use for those messages? Or will the _(macros)
survive the build process and be processed normally at run-time?


Hamish

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations
Glynn Clements

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink

Hamish wrote:

> > My suggestion is:
> >
> > Index: include/glocale.h
> > ===================================================================
> > RCS file: /grassrepository/grass6/include/glocale.h,v
> > retrieving revision 2.2
> > diff -u -r2.2 glocale.h
> > --- include/glocale.h   26 Nov 2006 21:32:36 -0000      2.2
> > +++ include/glocale.h   13 Dec 2006 18:51:56 -0000
> > @@ -1,6 +1,11 @@
> >  #ifndef GRASS_GLOCALE_H
> >  #define GRASS_GLOCALE_H
> >
> > +#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
> > +#define ERRMSG_VECTOR_OPEN_FILE        _("Unable to find vector map <%s>")
> > +#define ERRMSG_ASCII_OPEN_FILE        _("Unable to find ASCII file <%s>")
> > +#define ERRMSG_OTHER_OPEN_FILE        _("Unable to find file <%s>")
>
>
> Will that hardcode whatever language GRASS was built with as the
> only translation it can use for those messages? Or will the _(macros)
> survive the build process and be processed normally at run-time?

Macros are substituted by the preprocessor, so there's no difference
between:

        G_fatal_error(ERRMSG_RASTER_OPEN_FILE, mapname);
and:
        G_fatal_error(_("Unable to find raster map <%s>"), mapname);

so far as the resulting object file is concerned.

In either case, the code which is actually compiled will be either:

        G_fatal_error(("Unable to find raster map <%s>"), mapname);
or:
        G_fatal_error(G_gettext(PACKAGE,("Unable to find raster map <%s>")), mapname);

depending upon whether I18N is enabled (in the latter case, PACKAGE
will have been expanded to either "grasslibs" or "grassmods").

--
Glynn Clements <[hidden email]>

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations
Jáchym Čepický-2

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink
hi,
I tryed this patch for glocale.h, which sets standard messages, which
should be used in all grass modules.

it worked for r.average quite well, but when I updated .po files, new
messages did not appear.

could someone tell me, how to add glocale.h to list of files, which are
searched trough by running "make pot" ?

thanks

Jachym

On Thu, Dec 14, 2006 at 10:55:31AM +0000, Glynn Clements wrote:

>
> Hamish wrote:
>
> > > My suggestion is:
> > >
> > > Index: include/glocale.h
> > > ===================================================================
> > > RCS file: /grassrepository/grass6/include/glocale.h,v
> > > retrieving revision 2.2
> > > diff -u -r2.2 glocale.h
> > > --- include/glocale.h   26 Nov 2006 21:32:36 -0000      2.2
> > > +++ include/glocale.h   13 Dec 2006 18:51:56 -0000
> > > @@ -1,6 +1,11 @@
> > >  #ifndef GRASS_GLOCALE_H
> > >  #define GRASS_GLOCALE_H
> > >
> > > +#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
> > > +#define ERRMSG_VECTOR_OPEN_FILE        _("Unable to find vector map <%s>")
> > > +#define ERRMSG_ASCII_OPEN_FILE        _("Unable to find ASCII file <%s>")
> > > +#define ERRMSG_OTHER_OPEN_FILE        _("Unable to find file <%s>")
> >
> >
> > Will that hardcode whatever language GRASS was built with as the
> > only translation it can use for those messages? Or will the _(macros)
> > survive the build process and be processed normally at run-time?
>
> Macros are substituted by the preprocessor, so there's no difference
> between:
>
> G_fatal_error(ERRMSG_RASTER_OPEN_FILE, mapname);
> and:
> G_fatal_error(_("Unable to find raster map <%s>"), mapname);
>
> so far as the resulting object file is concerned.
>
> In either case, the code which is actually compiled will be either:
>
> G_fatal_error(("Unable to find raster map <%s>"), mapname);
> or:
> G_fatal_error(G_gettext(PACKAGE,("Unable to find raster map <%s>")), mapname);
>
> depending upon whether I18N is enabled (in the latter case, PACKAGE
> will have been expanded to either "grasslibs" or "grassmods").
>
> --
> Glynn Clements <[hidden email]>
>
> _______________________________________________
> grass-dev mailing list
> [hidden email]
> http://grass.itc.it/mailman/listinfo/grass-dev
--
Jachym Cepicky
e-mail: [hidden email]
URL: http://les-ejk.cz
GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
-----------------------------------------  
OFFICE:                                    
Department of Geoinformation Technologies
Zemedelska 3
613 00, Brno
Czech Republick
e-mail: [hidden email]
URL:    http://mapserver.mendelu.cz
Tel.:   +420 545 134 514


_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations

signature.asc (196 bytes) Download Attachment
Paul Kelly

Re: [GRASS-dev] Re: fprintf in raster modules converted to G_message

Reply Threaded More More options
Print post
Permalink


On Sat, 23 Dec 2006, Jachym Cepicky wrote:

> hi,
> I tryed this patch for glocale.h, which sets standard messages, which
> should be used in all grass modules.

FWIW I don't like this idea, as it means (IIUC) that you can't grep for
error messages in source files. Makes debugging a pain and is something
that really annoys me with other software packages that do something
similar. I don't see any advantage in using these macros over simply
changing non-standard text strings to whichever ones we decide are
standard?

> it worked for r.average quite well, but when I updated .po files, new
> messages did not appear.

But are they not old messages - they are already used in other modules?
But I don't know how the translation stuff works??

Paul

>
> could someone tell me, how to add glocale.h to list of files, which are
> searched trough by running "make pot" ?
>
> thanks
>
> Jachym
>
> On Thu, Dec 14, 2006 at 10:55:31AM +0000, Glynn Clements wrote:
>>
>> Hamish wrote:
>>
>>>> My suggestion is:
>>>>
>>>> Index: include/glocale.h
>>>> ===================================================================
>>>> RCS file: /grassrepository/grass6/include/glocale.h,v
>>>> retrieving revision 2.2
>>>> diff -u -r2.2 glocale.h
>>>> --- include/glocale.h   26 Nov 2006 21:32:36 -0000      2.2
>>>> +++ include/glocale.h   13 Dec 2006 18:51:56 -0000
>>>> @@ -1,6 +1,11 @@
>>>>  #ifndef GRASS_GLOCALE_H
>>>>  #define GRASS_GLOCALE_H
>>>>
>>>> +#define ERRMSG_RASTER_OPEN_FILE        _("Unable to find raster map <%s>")
>>>> +#define ERRMSG_VECTOR_OPEN_FILE        _("Unable to find vector map <%s>")
>>>> +#define ERRMSG_ASCII_OPEN_FILE        _("Unable to find ASCII file <%s>")
>>>> +#define ERRMSG_OTHER_OPEN_FILE        _("Unable to find file <%s>")
>>>
>>>
>>> Will that hardcode whatever language GRASS was built with as the
>>> only translation it can use for those messages? Or will the _(macros)
>>> survive the build process and be processed normally at run-time?
>>
>> Macros are substituted by the preprocessor, so there's no difference
>> between:
>>
>> G_fatal_error(ERRMSG_RASTER_OPEN_FILE, mapname);
>> and:
>> G_fatal_error(_("Unable to find raster map <%s>"), mapname);
>>
>> so far as the resulting object file is concerned.
>>
>> In either case, the code which is actually compiled will be either:
>>
>> G_fatal_error(("Unable to find raster map <%s>"), mapname);
>> or:
>> G_fatal_error(G_gettext(PACKAGE,("Unable to find raster map <%s>")), mapname);
>>
>> depending upon whether I18N is enabled (in the latter case, PACKAGE
>> will have been expanded to either "grasslibs" or "grassmods").
>>
>> --
>> Glynn Clements <[hidden email]>
>>
>> _______________________________________________
>> grass-dev mailing list
>> [hidden email]
>> http://grass.itc.it/mailman/listinfo/grass-dev
>
> --
> Jachym Cepicky
> e-mail: [hidden email]
> URL: http://les-ejk.cz
> GPG: http://www.les-ejk.cz/pgp/jachym_cepicky-gpg.pub
> -----------------------------------------
> OFFICE:
> Department of Geoinformation Technologies
> Zemedelska 3
> 613 00, Brno
> Czech Republick
> e-mail: [hidden email]
> URL:    http://mapserver.mendelu.cz
> Tel.:   +420 545 134 514
>

_______________________________________________
translations mailing list
[hidden email]
http://grass.itc.it/mailman/listinfo/translations