Explicitly set Khoj to use the default locale of the user (#425)

- Explicitly set locale using `locale.setLocale(locale.LC_ALL, '')` for localization. Relevant for datetime libraries. See [Python 3 documentation](https://docs.python.org/3/library/locale.html#locale.setlocale).
This commit is contained in:
sabaimran 2023-08-07 16:23:24 +00:00 committed by GitHub
parent cc951450fb
commit 738cf650b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@
import os import os
import signal import signal
import sys import sys
import locale
if sys.stdout is None: if sys.stdout is None:
sys.stdout = open(os.devnull, "w") sys.stdout = open(os.devnull, "w")
@ -32,6 +33,9 @@ from khoj.utils.cli import cli
# Initialize the Application Server # Initialize the Application Server
app = FastAPI() app = FastAPI()
# Set Locale
locale.setlocale(locale.LC_ALL, "")
# Setup Logger # Setup Logger
rich_handler = RichHandler(rich_tracebacks=True) rich_handler = RichHandler(rich_tracebacks=True)
rich_handler.setFormatter(fmt=logging.Formatter(fmt="%(message)s", datefmt="[%X]")) rich_handler.setFormatter(fmt=logging.Formatter(fmt="%(message)s", datefmt="[%X]"))