A Diumenge, 10 de juliol de 2011 12:52:58, Cédric Krier va escriure:
> On 10/07/11 12:39 +0200, Albert Cervera i Areny wrote:
> > One of the things I really miss in Tryton is the possibility of raising
> > messages using translatable strings in a gettext-like syntax.
>
> Did you take a look at "raise_user_error" and "raise_warning_error" ?
Yes, saw those ones.
> > I've been taking
> > a look at older messages in the list and the latest thread I could find
> > was almost two years ago [1] and it concentrated on changing the
> > translation engine, not how texts are marked for translation.
> >
> > Would a patch that accepted the _("The whole message") syntax be welcomed
> > or is the current syntax preferred for some reason?
>
> For me using the gettext syntax will bring misunderstading for the
> developper who will think it works like gettext.
Well, gettext syntax (or similar) is widely used and each version has its
differences, I think. Qt uses tr() which is not exactly like gettext but the
idea is the same and IMHO it's more practical than having to declare all
translatable strings first and then using them in the code. In modules in which
there can be many exceptions, I think having to declare the text before is
what I do not like. I personally do not mind if _() is used or one simply
could call raise_user_error() without the need of declaring the string first.
Previous declaration also forces the developer to remember if/what parameters
it must pass to the translatable string.
> Right now, the translation mechanism gives you the precise place where the
> string is used but not depending on the position (line) where it is.
> Also the gettext syntax just doesn't give you the Model from which the
> string comes.
You're right. As I said, if self.raise_user_error() (or equivalent function)
accepted the complete string without pre-declaration it would do the job for
me.
> More over, it will require to parse the python file for those string
> instead of just using the python runtime.
Of course, my suggestion of raise_user_error() without pre-declaration would
require that too, but I don't see it much of a problem if it helps developers.
After all most of open source projects are already doing that and there're
tools which make it really easy to do it.
> So I don't see any advantage but just confusion.
--
Albert Cervera i Areny
http://www.NaN-tic.com
OpenERP Partners
Tel: +34 93 553 18 03
http://twitter.com/albertnan
http://www.nan-tic.com/blog
--
[email protected] mailing list