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
changes/02/666602/3
Ivan Kolodyazhny 3 years ago
parent c6f19dc6d6
commit 4e911e2889
  1. 17
      doc/source/configuration/settings.rst
  2. 14
      openstack_dashboard/settings.py

@ -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
<https://docs.djangoproject.com/en/2.2/ref/settings/#locale-paths>`_
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.

@ -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.

Loading…
Cancel
Save