Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

fix locale discovery by django app

jonaswinklerbf198f37db7c
diff --git a/src/documents/templates/index.html b/src/documents/templates/index.html
index 753aa766c..21112b643 100644
--- a/src/documents/templates/index.html
+++ b/src/documents/templates/index.html
@@ -12,7 +12,7 @@
<meta name="full_name" content="{{full_name}}">
<meta name="cookie_prefix" content="{{cookie_prefix}}">
<link rel="icon" type="image/x-icon" href="favicon.ico">
- <link rel="manifest" href="{% static 'frontend/manifest.webmanifest' %}">
+ <link rel="manifest" href="{% static webmanifest %}">
<link rel="stylesheet" href="{% static styles_css %}">
</head>
<body>
diff --git a/src/documents/views.py b/src/documents/views.py
index 7dc3ae3e6..8af29ce05 100755
--- a/src/documents/views.py
+++ b/src/documents/views.py
@@ -57,15 +57,29 @@ from .serialisers import (
class IndexView(TemplateView):
template_name = "index.html"
+ def get_language(self):
+ # This is here for the following reason:
+ # Django identifies languages in the form "en-us"
+ # However, angular generates locales as "en-US".
+ # this translates between these two forms.
+ lang = get_language()
+ if "-" in lang:
+ first = lang[:lang.index("-")]
+ second = lang[lang.index("-")+1:]
+ return f"{first}-{second.upper()}"
+ else:
+ return lang
+
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['cookie_prefix'] = settings.COOKIE_PREFIX
context['username'] = self.request.user.username
context['full_name'] = self.request.user.get_full_name()
- context['styles_css'] = f"frontend/{get_language()}/styles.css"
- context['runtime_js'] = f"frontend/{get_language()}/runtime.js"
- context['polyfills_js'] = f"frontend/{get_language()}/polyfills.js"
- context['main_js'] = f"frontend/{get_language()}/main.js"
+ context['styles_css'] = f"frontend/{self.get_language()}/styles.css"
+ context['runtime_js'] = f"frontend/{self.get_language()}/runtime.js"
+ context['polyfills_js'] = f"frontend/{self.get_language()}/polyfills.js" # NOQA: E501
+ context['main_js'] = f"frontend/{self.get_language()}/main.js"
+ context['manifest'] = f"frontend/{self.get_language()}/manifest.webmanifest" # NOQA: E501
return context
diff --git a/src/paperless/urls.py b/src/paperless/urls.py
index 6adb1be5b..49e6e8b7a 100755
--- a/src/paperless/urls.py
+++ b/src/paperless/urls.py
@@ -90,7 +90,7 @@ urlpatterns = [
# Frontend assets TODO: this is pretty bad, but it works.
path('assets/<path:path>',
- RedirectView.as_view(url='/static/frontend/en-us/assets/%(path)s')),
+ RedirectView.as_view(url='/static/frontend/en-US/assets/%(path)s')),
# TODO: with localization, this is even worse! :/
# login, logout