2009/4/23 Álvaro Justen [Turicas] <[email protected]>: > On Thu, Apr 23, 2009 at 7:22 PM, Álvaro Justen [Turicas] > <[email protected]> wrote: >> On Thu, Apr 23, 2009 at 6:59 PM, mdipierro <[email protected]> wrote: >>> The problem is that T cannot appear in web2py modules because they are >>> imported before T is defined. T is a global variable defined after a >>> request arrives. >>> >>> What you need to do is customize Auth as described in >>> http://www.web2py.com/examples/default/tools and add the Ts. Then you >>> translated them in languages. >> >> Yes, I understand and using this system right now, but I think if >> there is a translation system, so web2py must translate all strings >> out-of-the-box. > > I did some modifications in gluon/tools.py to support full translation > system and it worked! :-D > > I added __getattr__ in class Auth, so all attributes are translated > when Auth needs to use self.messages.blablabla (and in this time, > self.environment.T is avaible). > > I created a class called tmpclass to handle self.messages.bla > (__getattr__ from Auth only can handle self.bla), but if we modify > self.messages.X to self.X or self.msg[X] we can delete this class. I > think the optimal case is to delete tmpclass, change all > self.messages.bla to self.msgs['bla'] and handle all messages in > Auth's __getattr__. > > Well, this is working and I think we can do this in all classes, so > web2py will have a full translation system built-in. > > I'm attaching my new gluon/tools.py (all old code are in """...""") > and pt-br.py (translated only 'Invalid login' message). > > Massimo, what do you think?
OK, it is backward incompatible, but we can add a __setattr__ method. -- Álvaro Justen Peta5 - Telecomunicações e Software Livre 21 3021-6001 / 9898-0141 http://www.peta5.com.br/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

