[Scilab-users] Behavior of gettext

classic Classic list List threaded Threaded
8 messages Options
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Behavior of gettext


Dear all,

I'm trying to understand the way the localizing function gettext works.
For instance,

setlanguage('es')     // Set Spanish as session language
gettext("%s: Wrong number of input arguments.\n")

produces the expected result:

%s: Número incorrecto de argumentos de entrada.\n

But

gettext("Wrong number of input arguments.")

returns the original English version

Wrong number of input arguments.

Are the elements %s and \n part of the indexed string?

How can I get a list of indexed strings?

Regards,

Federico Miyara



---
El software de antivirus Avast ha analizado este correo electrónico en busca de virus.
https://www.avast.com/antivirus

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext

Hello Federico,


Le 04/03/2019 à 05:58, Federico Miyara a écrit :

Dear all,

I'm trying to understand the way the localizing function gettext works. For instance,

setlanguage('es')     // Set Spanish as session language
gettext("%s: Wrong number of input arguments.\n")

produces the expected result:

%s: Número incorrecto de argumentos de entrada.\n

But

gettext("Wrong number of input arguments.")

returns the original English version

Wrong number of input arguments.

Are the elements %s and \n part of the indexed string?

Yes. The string provided to gettext() is an identifier. So changing any single character of it then refers to another message.

You might have already had a look at the gettext page: https://help.scilab.org/docs/6.0.2/en_US/gettext.html


How can I get a list of indexed strings?

The most frequent ones are newly listed in
--> help error_table

https://help.scilab.org/docs/6.0.2/en_US/error_table.html
For an exhaustive list, please
  • Download and unzip the source code : https://www.scilab.org/previous-scilab-versions
  • In your OS file browser, from the root directory of the source tree, select all *.pot files (roughtly 1 hundred of files)
  • Edit *.pot files. They are unformatted text files. Each one gathers all gettext messages identifiers for a native Scilab module.


Hope This Helps

Samuel



_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext


Dear Samuel,

Thank you very much. I had read the gettext help but it is not as clear as it should, it was not clear for me if the indexed strings were the complete error message including the formatting details or the plain English version within it. Now it is more clear. What is still not cleaer is if the only use of getttext is to localize errore messages or it is possible to localize a GUI without formatting.

Regards,

Federico Miyara



On 04/03/2019 14:29, Samuel Gougeon wrote:
Hello Federico,


Le 04/03/2019 à 05:58, Federico Miyara a écrit :

Dear all,

I'm trying to understand the way the localizing function gettext works. For instance,

setlanguage('es')     // Set Spanish as session language
gettext("%s: Wrong number of input arguments.\n")

produces the expected result:

%s: Número incorrecto de argumentos de entrada.\n

But

gettext("Wrong number of input arguments.")

returns the original English version

Wrong number of input arguments.

Are the elements %s and \n part of the indexed string?

Yes. The string provided to gettext() is an identifier. So changing any single character of it then refers to another message.

You might have already had a look at the gettext page: https://help.scilab.org/docs/6.0.2/en_US/gettext.html


How can I get a list of indexed strings?

The most frequent ones are newly listed in
--> help error_table

https://help.scilab.org/docs/6.0.2/en_US/error_table.html
For an exhaustive list, please
  • Download and unzip the source code : https://www.scilab.org/previous-scilab-versions
  • In your OS file browser, from the root directory of the source tree, select all *.pot files (roughtly 1 hundred of files)
  • Edit *.pot files. They are unformatted text files. Each one gathers all gettext messages identifiers for a native Scilab module.


Hope This Helps

Samuel




_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext

Le 06/03/2019 à 00:56, Federico Miyara a écrit :
>
> Dear Samuel,
>
> Thank you very much. I had read the gettext help but it is not as
> clear as it should, it was not clear for me if the indexed strings
> were the complete error message including the formatting details or
> the plain English version within it. Now it is more clear. What is
> still not cleaer is if the only use of getttext is to localize errore
> messages or it is possible to localize a GUI without formatting.

gettext() is used to register and translate any message: warnings,
menus, titles, etc etc. Whatever you want. Just edit .pot files : The
sources files where the messages are registered (so gettext("...") is
called) are all indicated, in Scilab files, in files in C, C++..

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext


Dear All,

I try to get this error message translated:

msprintf
(gettext("%s: Argument #%d: Vector expected.\n"), "bandfilter", 1)

Any idea of what's wrong?

This one works fine:


msprintf
(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"), "bandfilter", 2, 4)

Both messages were taken from the error_table documentation.

Federico Miyara


On 06/03/2019 18:02, Samuel Gougeon wrote:
Le 06/03/2019 à 00:56, Federico Miyara a écrit :

Dear Samuel,

Thank you very much. I had read the gettext help but it is not as clear as it should, it was not clear for me if the indexed strings were the complete error message including the formatting details or the plain English version within it. Now it is more clear. What is still not cleaer is if the only use of getttext is to localize errore messages or it is possible to localize a GUI without formatting.

gettext() is used to register and translate any message: warnings, menus, titles, etc etc. Whatever you want. Just edit .pot files : The sources files where the messages are registered (so gettext("...") is called) are all indicated, in Scilab files, in files in C, C++..

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users




Libre de virus. www.avast.com

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext

Hello,

Le 12/03/2019 à 21:31, Federico Miyara a écrit :

Dear All,

I try to get this error message translated:

msprintf
(gettext("%s: Argument #%d: Vector expected.\n"), "bandfilter", 1)

It may be a very recent one, not yet translated.

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext

In reply to this post by fmiyara
Le 12/03/2019 à 21:31, Federico Miyara a écrit :

Dear All,

I try to get this error message translated:

msprintf
(gettext("%s: Argument #%d: Vector expected.\n"), "bandfilter", 1)

Any idea of what's wrong?

The long historical form is
gettext("%s: Wrong size for argument #%d: Vector expected.\n")

When some students or colleagues ask me for help, i have noticed that quite often they did not really read the error message, and i wondered why.
Often, IMO error messages are uselessly verbosy. This is why i proposed
a series of shorter, more straightforward, and more orthogonal ones.

Samuel


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
fmiyara fmiyara
Reply | Threaded
Open this post in threaded view
|

Re: Behavior of gettext


Thank you Samuel, this one does work!

I understand the verbosity issue (it's the age of SMS's and WhatsApp's). However, the "orthogonality", in spite of being a good idea to avoid many instances of similar messages, would be really useful if some way to combine short messages did exist. But I'm afraid it is a very hard problem since the way things combine in different languages may be quite different, particularly word order.

Federico
  


On 12/03/2019 21:19, Samuel Gougeon wrote:
Le 12/03/2019 à 21:31, Federico Miyara a écrit :

Dear All,

I try to get this error message translated:

msprintf
(gettext("%s: Argument #%d: Vector expected.\n"), "bandfilter", 1)

Any idea of what's wrong?

The long historical form is
gettext("%s: Wrong size for argument #%d: Vector expected.\n")

When some students or colleagues ask me for help, i have noticed that quite often they did not really read the error message, and i wondered why.
Often, IMO error messages are uselessly verbosy. This is why i proposed
a series of shorter, more straightforward, and more orthogonal ones.

Samuel


Libre de virus. www.avg.com


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users