On Jan 3, 12:47 am, Jaroslaw Zabiello <[email protected]> wrote:
> I do not like the way web2py distinguish 'en' and 'en-en' as two
> different languages, so I wrote a simple code which fix it.
>
> lang = request.env.http_accept_language.split(',')[0].split(';')
> [0].split('-')[0]
> if lang not in [all_available_languages]: lang = DEFAULT_LANG
> T.force(lang)
This is not necessary. Just do
T.current_languages=[DEFAULT_LANG]
> I have also few questions.
>
> 1. Where to put Python code which should be shared by all web2py
> controllers but also parsed on *every* request? I found that T.force()
> has to be executed BEFORE any T() method is used otherwise it won't
> work.
You can put it in a model file or in a module and import the module.
T.force() does not need to be executed before any T(). It only need to
be executed before T() is serialized in a string via str() or
{{=...}}.
> 2. Where is the best place for global variables (variables available
> in all controllers, but parsed only once)
In models
> 3. Is there any API for extracting all translation languages used in
> the project? I would like to get the list of all available languages.
In the admin/design page
> 4. How to get absolute filepath to the current application?
request.folder
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---