mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	fix locale discovery by django app
This commit is contained in:
		| @@ -12,7 +12,7 @@ | |||||||
| 	<meta name="full_name" content="{{full_name}}"> | 	<meta name="full_name" content="{{full_name}}"> | ||||||
| 	<meta name="cookie_prefix" content="{{cookie_prefix}}"> | 	<meta name="cookie_prefix" content="{{cookie_prefix}}"> | ||||||
|   <link rel="icon" type="image/x-icon" href="favicon.ico"> |   <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 %}"> | 	<link rel="stylesheet" href="{% static styles_css %}"> | ||||||
| </head> | </head> | ||||||
| <body> | <body> | ||||||
|   | |||||||
| @@ -57,15 +57,29 @@ from .serialisers import ( | |||||||
| class IndexView(TemplateView): | class IndexView(TemplateView): | ||||||
|     template_name = "index.html" |     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): |     def get_context_data(self, **kwargs): | ||||||
|         context = super().get_context_data(**kwargs) |         context = super().get_context_data(**kwargs) | ||||||
|         context['cookie_prefix'] = settings.COOKIE_PREFIX |         context['cookie_prefix'] = settings.COOKIE_PREFIX | ||||||
|         context['username'] = self.request.user.username |         context['username'] = self.request.user.username | ||||||
|         context['full_name'] = self.request.user.get_full_name() |         context['full_name'] = self.request.user.get_full_name() | ||||||
|         context['styles_css'] = f"frontend/{get_language()}/styles.css" |         context['styles_css'] = f"frontend/{self.get_language()}/styles.css" | ||||||
|         context['runtime_js'] = f"frontend/{get_language()}/runtime.js" |         context['runtime_js'] = f"frontend/{self.get_language()}/runtime.js" | ||||||
|         context['polyfills_js'] = f"frontend/{get_language()}/polyfills.js" |         context['polyfills_js'] = f"frontend/{self.get_language()}/polyfills.js"  # NOQA: E501 | ||||||
|         context['main_js'] = f"frontend/{get_language()}/main.js" |         context['main_js'] = f"frontend/{self.get_language()}/main.js" | ||||||
|  |         context['manifest'] = f"frontend/{self.get_language()}/manifest.webmanifest"  # NOQA: E501 | ||||||
|         return context |         return context | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -90,7 +90,7 @@ urlpatterns = [ | |||||||
|  |  | ||||||
|     # Frontend assets TODO: this is pretty bad, but it works. |     # Frontend assets TODO: this is pretty bad, but it works. | ||||||
|     path('assets/<path:path>', |     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! :/ |     # TODO: with localization, this is even worse! :/ | ||||||
|  |  | ||||||
|     # login, logout |     # login, logout | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 jonaswinkler
					jonaswinkler