Fix #1767: cms.utils.i18n.get_fallback_languages may fail if LANGUAGES has more languages than CMS_LANGUAGES #1768

Merged
merged 2 commits into from Mar 12, 2014

Projects

None yet

4 participants

@ojii
Collaborator
ojii commented May 5, 2013

If cms.utils.i18n.get_fallback_languages is called with a language not available in CMS_LANGUAGES for the current site, return fallbacks of first language in that site.

Fixes #1767

@ojii
Collaborator
ojii commented May 5, 2013

apparently more issues surfaced. see:

Traceback:
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  115.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/views.py" in details
  148.     return render_to_response(template_name, context_instance=context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render_to_response
  29.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
  177.         return t.render(context_instance)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in render
  140.             return self._render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in render
  830.                 bit = self.render_node(node, context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/loader_tags.py" in render
  124.         return compiled_parent._render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in _render
  134.         return self.nodelist.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in render
  830.                 bit = self.render_node(node, context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/classytags/core.py" in render
  106.         return self.render_tag(context, **kwargs)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/sekizai/templatetags/sekizai_tags.py" in render_tag
  76.         rendered_contents = nodelist.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/base.py" in render
  830.                 bit = self.render_node(node, context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/django/template/debug.py" in render_node
  74.             return node.render(context)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/classytags/core.py" in render
  106.         return self.render_tag(context, **kwargs)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in render_tag
  264.         content = get_placeholder_content(context, request, page, name, inherit)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in get_placeholder_content
  177.         placeholder = _get_placeholder(current_page, page, context, name)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/templatetags/cms_tags.py" in _get_placeholder
  160.     assign_plugins(context['request'], placeholders, get_language())
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/plugins/utils.py" in assign_plugins
  37.         if not lang in languages and not get_redirect_on_fallback(lang):
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/utils/i18n.py" in get_redirect_on_fallback
  175.     language = get_language_object(language, site_id)
File "/Users/gabejackson/venv/www.designholz.ch/lib/python2.7/site-packages/cms/utils/i18n.py" in get_language_object
  122.     raise LanguageError('Language not found: %s' % language_code)

Exception Type: LanguageError at /
Exception Value: Language not found: en
@digi604
Member
digi604 commented May 6, 2013

could you open that for 2.4.x?

@ojii
Collaborator
ojii commented May 6, 2013

Have to first figure out how to properly fix this.

@yakky
Collaborator
yakky commented May 18, 2013

Event after fixing this, does #1766 still need the s/ugettext_lazy/ugettext/ fix?

@czpython czpython was assigned Aug 30, 2013
@digi604 digi604 assigned digi604 and unassigned czpython Feb 10, 2014
@digi604 digi604 merged commit 532d0b4 into divio:develop Mar 12, 2014

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment