summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-06 09:46:01 +0000
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-12-06 09:46:01 +0000
commitb300f00c14270a3a5e2f52332259090ccc3c919d (patch)
tree0e607797cac7bb925c8b569804d5db479e47506c
parented14a87d9912f504cfe513b9db9765e4590aa52f (diff)
downloadpykolab-b300f00c14270a3a5e2f52332259090ccc3c919d.tar.gz
Add an default_locale setting to indicate the preferred system locale and default for all users
Add preferredLanguage setting to LDAP attributes obtained with a user account
-rw-r--r--pykolab/auth/ldap/__init__.py6
-rw-r--r--pykolab/conf/defaults.py4
-rw-r--r--pykolab/plugins/recipientpolicy/__init__.py4
3 files changed, 10 insertions, 4 deletions
diff --git a/pykolab/auth/ldap/__init__.py b/pykolab/auth/ldap/__init__.py
index f725d87..e7de7d2 100644
--- a/pykolab/auth/ldap/__init__.py
+++ b/pykolab/auth/ldap/__init__.py
@@ -1026,7 +1026,8 @@ class LDAP(object):
'sn',
'givenname',
'cn',
- 'uid'
+ 'uid',
+ 'preferredLanguage'
]:
if not user.has_key(attribute):
_get_attrs.append(attribute)
@@ -1037,6 +1038,9 @@ class LDAP(object):
for key in _user_attrs.keys():
user[key] = _user_attrs[key]
+ if user['preferredLanguage'] == None:
+ self._set_user_attribute(user, 'preferredLanguage', conf.get('ldap', 'default_locale'))
+
# Check to see if we want to apply a primary mail recipient policy
if conf.has_option(primary_domain, 'primary_mail'):
primary_mail = conf.plugins.exec_hook(
diff --git a/pykolab/conf/defaults.py b/pykolab/conf/defaults.py
index b109877..17f4724 100644
--- a/pykolab/conf/defaults.py
+++ b/pykolab/conf/defaults.py
@@ -29,4 +29,6 @@ class Defaults(object):
# library should try to retrieve annotations
self.cyrus_annotations_retry_interval = 1
- self.address_search_attrs = "mail, alias" \ No newline at end of file
+ self.address_search_attrs = "mail, alias"
+
+ self.default_locale = 'en_US'
diff --git a/pykolab/plugins/recipientpolicy/__init__.py b/pykolab/plugins/recipientpolicy/__init__.py
index 07204a2..1167eae 100644
--- a/pykolab/plugins/recipientpolicy/__init__.py
+++ b/pykolab/plugins/recipientpolicy/__init__.py
@@ -63,7 +63,7 @@ class KolabRecipientpolicy(object):
try:
mail = kw['primary_mail'] % user_attrs
- return utils.translate(mail.lower())
+ return utils.translate(mail.lower(), user['preferredLanguage'])
except KeyError, e:
log.warning(_("Attribute substitution for 'mail' failed in Recipient Policy"))
return user_attrs['mail'].lower()
@@ -105,7 +105,7 @@ class KolabRecipientpolicy(object):
log.warning(_("Attribute substitution for 'alternative_mail' failed in Recipient Policy"))
#log.debug(_("Appending additional mail address: %s") %(retval), level=8)
- alternative_mail.append(utils.translate(retval))
+ alternative_mail.append(utils.translate(retval), user['preferredLanguage'])
for _domain in kw['secondary_domains']:
user_attrs['domain'] = _domain