[gen] Bugfix while managing languages, ui improvements.
This commit is contained in:
parent
aaaccb0669
commit
ede29fb6c1
14 changed files with 140 additions and 96 deletions
|
@ -121,6 +121,13 @@ class ToolMixin(BaseMixin):
|
|||
p_code.'''
|
||||
return languages.get(code)[2]
|
||||
|
||||
def changeLanguage(self):
|
||||
'''Sets the language cookie with the new desired language code that is
|
||||
in request["language"].'''
|
||||
rq = self.REQUEST
|
||||
rq.RESPONSE.setCookie('_ZopeLg', rq['language'], path='/')
|
||||
return self.goto(rq['HTTP_REFERER'])
|
||||
|
||||
def getGlobalCssJs(self):
|
||||
'''Returns the list of CSS and JS files to include in the main template.
|
||||
The method ensures that appy.css and appy.js come first.'''
|
||||
|
@ -231,6 +238,12 @@ class ToolMixin(BaseMixin):
|
|||
res = appyObj.showPortlet()
|
||||
except AttributeError:
|
||||
res = True
|
||||
else:
|
||||
appyObj = self.appy()
|
||||
try:
|
||||
res = appyObj.showPortletAt(context)
|
||||
except AttributeError:
|
||||
res = True
|
||||
return res
|
||||
|
||||
def getObject(self, uid, appy=False, brain=False):
|
||||
|
@ -979,7 +992,7 @@ class ToolMixin(BaseMixin):
|
|||
elem is the one-line user info as shown on every page; second line is
|
||||
the URL to edit user info.'''
|
||||
appyUser = self.appy().appyUser
|
||||
res = [appyUser.title, appyUser.login]
|
||||
res = [appyUser.title]
|
||||
rolesToShow = [r for r in appyUser.roles \
|
||||
if r not in ('Authenticated', 'Member')]
|
||||
if rolesToShow:
|
||||
|
|
|
@ -1345,10 +1345,16 @@ class BaseMixin:
|
|||
def getUserLanguage(self):
|
||||
'''Gets the language (code) of the current user.'''
|
||||
if not hasattr(self, 'REQUEST'): return 'en'
|
||||
# Try first the "LANGUAGE" key from the request
|
||||
# Try the value which comes from the cookie. Indeed, if such a cookie is
|
||||
# present, it means that the user has explicitly chosen this language
|
||||
# via the language selector.
|
||||
rq = self.REQUEST
|
||||
if '_ZopeLg' in rq.cookies: return rq.cookies['_ZopeLg']
|
||||
# Try the LANGUAGE key from the request: it corresponds to the language
|
||||
# as configured in the user's browser.
|
||||
res = self.REQUEST.get('LANGUAGE', None)
|
||||
if res: return res
|
||||
# Try then the HTTP_ACCEPT_LANGUAGE key from the request, which stores
|
||||
# Try the HTTP_ACCEPT_LANGUAGE key from the request, which stores
|
||||
# language preferences as defined in the user's browser. Several
|
||||
# languages can be listed, from most to less wanted.
|
||||
res = self.REQUEST.get('HTTP_ACCEPT_LANGUAGE', None)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue