Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

error pages: Fix exceptions from missing request_language parameter.

Arjun-G-049e01f07a1eea
diff --git a/zerver/context_processors.py b/zerver/context_processors.py
index af716786752..00c5f90f192 100644
--- a/zerver/context_processors.py
+++ b/zerver/context_processors.py
@@ -36,6 +36,11 @@ from zproject.config import get_config
DEFAULT_PAGE_PARAMS: Mapping[str, Any] = {
"page_type": "default",
"development_environment": settings.DEVELOPMENT,
+ # This language is used to initialize i18n.ts to do translations
+ # in the user's language. Callers are expected to replace this
+ # with the user's detected language using get_language wherever
+ # possible.
+ "request_language": "en",
}
diff --git a/zproject/jinja2/__init__.py b/zproject/jinja2/__init__.py
index 2b6acec26f3..0b56e834c46 100644
--- a/zproject/jinja2/__init__.py
+++ b/zproject/jinja2/__init__.py
@@ -25,6 +25,11 @@ def environment(**options: Any) -> Environment:
# default_page_params is provided here for responses where
# zulip_default_context is not run, including the 404.html and
# 500.html error pages.
+ #
+ # Note that we can't use detect the user's language using
+ # get_language here, since this is only run once during
+ # process initialization. This is functionally OK, in that
+ # these error pages are translated on the server.
default_page_params=DEFAULT_PAGE_PARAMS,
static=staticfiles_storage.url,
url=reverse,