add userdefined value to get the language value from PR_LANGAUGE with en_GB as fallback

This commit is contained in:
Robin van Genderen 2019-03-04 11:27:28 +01:00
parent 2c564426b5
commit e76ae88edc

View File

@ -173,10 +173,18 @@ Change the language
"""
def language(user, language):
settings = read_settings(user)
# Get language from PR_LANGUAGE
if language == 'userdefined':
try:
language = user.prop(PR_LANGUAGE).value
except:
print('User language is not defined using en_GB as fallback'
language = 'en_GB'
if not settings['settings']['zarafa']['v1'].get('main'):
settings['settings']['zarafa']['v1']['main'] = {}
settings['settings']['zarafa']['v1']['main']['language'] = locale
print('Setting locale to: {}'.format(locale))
settings['settings']['zarafa']['v1']['main']['language'] = language
print('Setting locale to: {}'.format(language))
write_settings(user, json.dumps(settings))