Add webapp_switch_locale.py script
This commit is contained in:
parent
04bfd40c11
commit
def3c0edfa
21
readme.md
21
readme.md
@ -57,6 +57,25 @@ Dumps all the signatures in a users Webapp to seperate files, meant as companion
|
|||||||
The files will be written in the current directory.
|
The files will be written in the current directory.
|
||||||
|
|
||||||
#### Usage:
|
#### Usage:
|
||||||
```python
|
```
|
||||||
python dump_webapp_signatures.py --user user
|
python dump_webapp_signatures.py --user user
|
||||||
```
|
```
|
||||||
|
|
||||||
|
webapp_switch_locale.py
|
||||||
|
=========================
|
||||||
|
List or change the locale currently set in the user's WebApp settings.
|
||||||
|
|
||||||
|
#### Usage:
|
||||||
|
###### List locale
|
||||||
|
```
|
||||||
|
python switchlocale.py --user user1
|
||||||
|
Original locale: nl_NL.UTF-8
|
||||||
|
```
|
||||||
|
###### Change locale
|
||||||
|
```
|
||||||
|
python switchlocale.py --user user1 --locale de_DE.UTF-8
|
||||||
|
Original locale: nl_NL.UTF-8
|
||||||
|
Setting locale to: de_DE.UTF-8
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
35
webapp_switch_locale.py
Normal file
35
webapp_switch_locale.py
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
import json
|
||||||
|
import kopano
|
||||||
|
from MAPI.Util import *
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def opt_args():
|
||||||
|
parser = kopano.parser('skpcfm')
|
||||||
|
parser.add_option("--user", dest="user", action="store", help="Run script for user")
|
||||||
|
parser.add_option("--locale", dest="locale", action="store", help="Set new locale")
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
options, args = opt_args()
|
||||||
|
|
||||||
|
if not options.user:
|
||||||
|
print 'Please use:\n %s --user <username> [--locale]' % (sys.argv[0])
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
user = kopano.Server(options).user(options.user)
|
||||||
|
settings = json.loads(user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).value)
|
||||||
|
current = settings['settings']['zarafa']['v1']['main']['language']
|
||||||
|
print 'Original locale: %s' % current
|
||||||
|
|
||||||
|
if options.locale:
|
||||||
|
print 'Setting locale to: %s' % options.locale
|
||||||
|
settings['settings']['zarafa']['v1']['main']['language'] = options.locale
|
||||||
|
user.store.prop(PR_EC_WEBACCESS_SETTINGS_JSON).set_value(json.dumps(settings))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user