From 4e911e2889ebe7f0a577a0323649dceb9cef363c Mon Sep 17 00:00:00 2001 From: Ivan Kolodyazhny Date: Thu, 20 Jun 2019 14:55:48 +0000 Subject: [PATCH] Explicitly set LOCALE_PATHS for Horizon apps Set absolute paths in the LOCALE_PATHS configuration param to allow Django work with current supported locales. Change-Id: I62fffe04860b7b4b63f227ad99729ab4e8384d8f Related-Bug: #1818639 Closes-Bug: #1830886 --- doc/source/configuration/settings.rst | 17 +++++++++++++++++ openstack_dashboard/settings.py | 14 +++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/doc/source/configuration/settings.rst b/doc/source/configuration/settings.rst index cd60672c0e..d8906e738f 100644 --- a/doc/source/configuration/settings.rst +++ b/doc/source/configuration/settings.rst @@ -2504,3 +2504,20 @@ After the whole settings process has gone through, TEMPLATE_LOADERS will be: TEMPLATE_LOADERS += ( ('django.template.loaders.cached.Loader', CACHED_TEMPLATE_LOADERS), ) + tuple(ADD_TEMPLATE_LOADERS) + +LOCALE_PATHS +------------ + +.. versionadded:: 16.0.0(Train) + +.. seealso:: + + `Django's LOCALE_PATHS documentation + `_ + +Default: Absolute paths for `horizon/locale`, `openstack_auth/locale` and +`openstack_dashboard/locale` directories. + +Django uses relative paths by default so it causes localization issues +depending on your runtime settings. To avoid this we recommend to use absolute +paths for directories with locales. diff --git a/openstack_dashboard/settings.py b/openstack_dashboard/settings.py index 5af70cffee..9d963ea7de 100644 --- a/openstack_dashboard/settings.py +++ b/openstack_dashboard/settings.py @@ -25,8 +25,12 @@ import warnings from django.utils.translation import pgettext_lazy from django.utils.translation import ugettext_lazy as _ +import openstack_auth + +import horizon from horizon.utils.escape import monkeypatch_escape +import openstack_dashboard from openstack_dashboard import enabled from openstack_dashboard import exceptions from openstack_dashboard.local import enabled as local_enabled @@ -523,7 +527,15 @@ HORIZON_COMPRESS_OFFLINE_CONTEXT_BASE = { if DEBUG: logging.basicConfig(level=logging.DEBUG) - +# NOTE(e0ne): Set absolute paths for directories with localization. +# Django doesn't work well for Taiwanese locale with relative paths +# wich are used by default and I can't figure out at the moment why it +# works in this way. We don't use default Django templates, so it should +# be safe to have such defaults +LOCALE_PATHS = [ + os.path.join(os.path.dirname(os.path.abspath(m.__file__)), 'locale') + for m in (horizon, openstack_dashboard, openstack_auth) +] # Here comes the Django settings deprecation section. Being at the very end # of settings.py allows it to catch the settings defined in local_settings.py # or inside one of local_settings.d/ snippets.