Skip to content

Commit

Permalink
Change locale when language changes
Browse files Browse the repository at this point in the history
  • Loading branch information
titilambert committed Sep 11, 2017
1 parent 8be9d0a commit fc0dac4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,13 @@ jobs:
# Useless for now waiting for update from circleCI UI
- store_test_results:
path: pytest/
deployment:
rebuild_all_components:
commands:
- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/brain/tree/master?circle-token=$CIRCLE_TOKEN
- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/hotword-kittai/tree/master?circle-token=$CIRCLE_TOKEN
- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/speech-nuance/tree/master?circle-token=$CIRCLE_TOKEN
- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/nlu-nuance/tree/master?circle-token=$CIRCLE_TOKEN
- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/time/tree/master?circle-token=$CIRCLE_TOKEN
#- curl -v -X POST https://circleci.com/api/v1/project/github/TuxEatPi/being/tree/master?circle-token=$CIRCLE_TOKEN

4 changes: 2 additions & 2 deletions tuxeatpi_common/etcd_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def _connect(self):
# Save client
self.sync_client = etcd_client
break
except (etcd.EtcdConnectionFailed, urllib3.exceptions.MaxRetryError):
except (etcd.EtcdConnectionFailed, urllib3.exceptions.MaxRetryError, etcd.EtcdException):
self.logger.warning("Can not connect to etcd server, retrying in 5 seconds")
time.sleep(5)
# Get sync client sender
Expand All @@ -55,7 +55,7 @@ def _connect(self):
# Save client
self.sync_sender = etcd_sender
break
except (etcd.EtcdConnectionFailed, urllib3.exceptions.MaxRetryError):
except (etcd.EtcdConnectionFailed, urllib3.exceptions.MaxRetryError, etcd.EtcdException):
self.logger.warning("Can not connect to etcd server, retrying in 5 seconds")
time.sleep(5)
# Get async etcd client
Expand Down
4 changes: 4 additions & 0 deletions tuxeatpi_common/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import logging
import os
import json
import locale


class SettingsHandler(object):
Expand Down Expand Up @@ -79,6 +80,9 @@ async def read_global(self, watch=False):
if data.get('language') != self.language:
self.language = data['language']
self.logger.info("Language %s set", self.language)
# Set locale
encoding = locale.getlocale()[1]
locale.setlocale(locale.LC_ALL, (self.language, encoding))
# TODO Implement reload or not ???
self._reload_needed = True
self.logger.info("Reloading")
Expand Down

0 comments on commit fc0dac4

Please sign in to comment.