[gen] Allow to specify several folder within an app where to store static ui content (js, css, images). [gen] When browser settings are ignored or absent, default language is the first one listed in Config.languages.
This commit is contained in:
parent
d5a9450d72
commit
81a201dcad
|
@ -171,4 +171,8 @@ class Config:
|
|||
# When using a LDAP for authenticating users, place an instance of class
|
||||
# LdapConfig above in the field below.
|
||||
ldap = None
|
||||
# For an app, the default folder where to look for static content for the
|
||||
# user interface (CSS, Javascript and image files) is folder "ui" within
|
||||
# this app.
|
||||
uiFolders = ['ui']
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -66,8 +66,13 @@ class ZopeInstaller:
|
|||
# the one from the app-specific folder is chosen.
|
||||
j = os.path.join
|
||||
uiFolders = [j(j(appy.getPath(), 'gen'), 'ui')]
|
||||
appUi = j(self.config.diskFolder, 'ui')
|
||||
if os.path.exists(appUi): uiFolders.insert(0, appUi)
|
||||
for uiFolder in self.config.appConfig.uiFolders:
|
||||
if uiFolder.startswith('..'):
|
||||
folder = j(os.path.dirname(self.config.diskFolder),uiFolder[3:])
|
||||
else:
|
||||
folder = j(self.config.diskFolder, uiFolder)
|
||||
if os.path.exists(folder):
|
||||
uiFolders.insert(0, folder)
|
||||
for ui in uiFolders:
|
||||
for root, dirs, files in os.walk(ui):
|
||||
folderName = root[len(ui):]
|
||||
|
|
|
@ -1470,7 +1470,8 @@ class BaseMixin:
|
|||
|
||||
def getUserLanguage(self):
|
||||
'''Gets the language (code) of the current user.'''
|
||||
if not hasattr(self, 'REQUEST'): return 'en'
|
||||
if not hasattr(self, 'REQUEST'):
|
||||
return self.getProductConfig().appConfig.languages[0]
|
||||
# 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.
|
||||
|
@ -1484,7 +1485,7 @@ class BaseMixin:
|
|||
# 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)
|
||||
if not res: return 'en'
|
||||
if not res: return self.getProductConfig().appConfig.languages[0]
|
||||
if ',' in res: res = res[:res.find(',')]
|
||||
if '-' in res: res = res[:res.find('-')]
|
||||
return res
|
||||
|
|
Loading…
Reference in a new issue