Thanks, Yarko and Massimo
Yes, translation of messages in auth without T() worked :-)
I inserted
auth.messages.label_first_name = 'Given name'
into models/db.py
and, after hitting 'update all languages',
found an item 'Given name' in a language file for translation.
It's good to know how it works, thanx.
Now, as for ordering of first name and last name, gluon/tools.py has a
couple of
table.user_id.requires = IS_IN_DB(db, '%s.id' %
self.settings.table_user._tablename,
'%(id)s: %(first_name)s %(last_name)s')
As I mentioned before, in Japanese, family name comes first. So, I
may write
auth.messages.label_first_name = 'Family name'
auth.messages.label_last_name = 'Given name'
This is going to be confusing as a database.
Alternatively, I wonder if the requires statement above can be
modified like
self.messages.format_auth_dropdown_names = '%(id)s: %(first_name)s %
(last_name)s'
table.user_id.requires = IS_IN_DB(db, '%s.id' %
self.settings.table_user._tablename,
self.messages.format_auth_dropdown_names)
so that the string '%(id)s: %(first_name)s %(last_name)s' shows up in
a language file to be translated. Then, I could translate it as '%(id)
s: %(last_name)s %(first_name)s' for Japanese.
I'll appreciate comments.
--
Teru
On 8月9日, 午前10:23, Yarko Tymciurak <[email protected]> wrote:
> Ok - I see this is NOT an accurate assessment (but it is a little obtuse for
> looking at code);
>
> I caught the comments in README ("gluon.storage objects are now translated
> without T"), and meandered my way to the translator and lazyT classes in
> languages.py, and the one line environment setup of 'T' in
> compileapp.py/build_environment()
>
> Ok - I believe you ... it does this now.
>
> So, to focus back on this thread a little:
>
> sulato:
>
> You can rename the labels for first_name and last_name as you like in your
> application. To see all those labels translated (e.g. into Japanese), all
> you will need to do is provide the translations for the strings in
> auth.messages in a translation file - that should be it.
>
> We should probably add some comments in context from the readme into
> storage.py (once you know what you're looking at, then you can see that in
> class Messages(), the line:
>
> return str(self['T'](value))
>
> implicitly calls the __call__() method of the translator class - this really
> deserves a comment here, and probably at the head of the message section(s)
> in tools.py (that looks to be all).
>
> Massimo - ok if I add some brief comments and send a patch?
>
> - Yarko
>
> On Sat, Aug 8, 2009 at 6:33 PM, Yarko Tymciurak <[email protected]> wrote:
> > to clarify, it doesn't look to me like the default auth messages are
> > translatable unless the application author re-assigns them with T()
> > strings...
>
> > Is that an accurate assesment?
>
> > By lazy-assignment, I meant delayed processing of T() so that it picks up
> > the session settings; as it is, I see no default T() of the messages
> > anywhere...
>
> > On Sat, Aug 8, 2009 at 6:31 PM, Yarko Tymciurak <[email protected]> wrote:
>
> >> On Sat, Aug 8, 2009 at 6:19 PM, mdipierro <[email protected]>wrote:
>
> >>> > I wonder if some sort of lazy message assignment/translation would be
> >>> > reasonable / possible..
>
> >>> Already in trunk. ;-)
>
> >> Hmmmm..... this is not obvious to me... for example, how is translation
> >> handled for the messages?
>
> >> even after this post, and searching thru the code, I look at (for
> >> example) tools.py: Auth.retrieve_password(): line 1161:
>
> >> session.flash = self.messages.email_sent
>
> >> and nowhere do I see a re-assignment or opportunity for the
> >> messages.email_sent message to get T()'ified;
>
> >> Am I missing something?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py-users" 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
-~----------~----~----~----~------~----~------~--~---