Support for locale on gcalendar
This commit is contained in:
parent
55f3085c90
commit
80efa64614
1 changed files with 11 additions and 0 deletions
|
@ -11,6 +11,7 @@ Parameters:
|
||||||
* gcalendar.time_format: Format time output. Defaults to "%H:%M".
|
* gcalendar.time_format: Format time output. Defaults to "%H:%M".
|
||||||
* gcalendar.date_format: Format date output. Defaults to "%d.%m.%y".
|
* gcalendar.date_format: Format date output. Defaults to "%d.%m.%y".
|
||||||
* gcalendar.credentials_path: Path to credentials.json. Defaults to "~/".
|
* gcalendar.credentials_path: Path to credentials.json. Defaults to "~/".
|
||||||
|
* gcalendar.locale: locale to use rather than the system default.
|
||||||
|
|
||||||
Requires these pip packages:
|
Requires these pip packages:
|
||||||
* google-api-python-client
|
* google-api-python-client
|
||||||
|
@ -30,6 +31,7 @@ import core.decorators
|
||||||
import datetime
|
import datetime
|
||||||
import os.path
|
import os.path
|
||||||
import pickle
|
import pickle
|
||||||
|
import locale
|
||||||
|
|
||||||
from google.auth.transport.requests import Request
|
from google.auth.transport.requests import Request
|
||||||
from google.oauth2.credentials import Credentials
|
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.__credentials = os.path.join(self.__credentials_path, "credentials.json")
|
||||||
self.__token = os.path.join(self.__credentials_path, ".gcalendar_token.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):
|
def first_event(self, widget):
|
||||||
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
|
SCOPES = ["https://www.googleapis.com/auth/calendar.readonly"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue