diff --git a/bumblebee_status/modules/contrib/gcalendar.py b/bumblebee_status/modules/contrib/gcalendar.py index 769a24b..6d0f4ed 100644 --- a/bumblebee_status/modules/contrib/gcalendar.py +++ b/bumblebee_status/modules/contrib/gcalendar.py @@ -11,6 +11,7 @@ Parameters: * gcalendar.time_format: Format time output. Defaults to "%H:%M". * gcalendar.date_format: Format date output. Defaults to "%d.%m.%y". * gcalendar.credentials_path: Path to credentials.json. Defaults to "~/". + * gcalendar.locale: locale to use rather than the system default. Requires these pip packages: * google-api-python-client @@ -30,6 +31,7 @@ import core.decorators import datetime import os.path import pickle +import locale from google.auth.transport.requests import Request from google.oauth2.credentials import Credentials @@ -50,6 +52,15 @@ class Module(core.module.Module): self.__credentials = os.path.join(self.__credentials_path, "credentials.json") self.__token = os.path.join(self.__credentials_path, ".gcalendar_token.json") + l = locale.getdefaultlocale() + if not l or l == (None, None): + l = ("en_US", "UTF-8") + lcl = self.parameter("locale", ".".join(l)) + try: + locale.setlocale(locale.LC_TIME, lcl.split(".")) + except Exception: + locale.setlocale(locale.LC_TIME, ("en_US", "UTF-8")) + def first_event(self, widget): SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]