New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix bug 1222137] Enable bedrock locale-based templates. #3880
[fix bug 1222137] Enable bedrock locale-based templates. #3880
Conversation
Hm, tests are all passing locally... |
pass | ||
|
||
# Render try #2: Look for locale-specific template in app/templates/ | ||
locale_tmpl = template.replace('.html', '.' + request.locale + '.html') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be more robust to use some stdlib tools here:
>>> from os.path import splitext
>>> template = 'los-angles/laziest/dude.html'
>>> '.{}'.format('pt-BR').join(splitext(template))
'los-angles/laziest/dude.pt-BR.html'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Hmm. This looks good, but tests failing. Looks like an unapplied mock. Likely due to from lib import l10n_utils
@patch.object(l10n_utils, 'django_render')
class ... You'd have to change calls to |
@@ -125,3 +127,53 @@ def test_render_no_locale(self, django_render, get_lang_path): | |||
# Note: no .locale on request | |||
# Should not cause an exception | |||
render(request, '500.html') | |||
|
|||
|
|||
@patch.object(l10n_utils, 'django_render') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also have to patch template_is_active
.
@patch('lib.l10n_utils.template_is_active', Mock(return_value=True))
@patch('lib.l10n_utils.django_render')
That set of patches works for me.
3cc15ef
to
62f0107
Compare
Yay! I think we're good here. Let me check one more time. |
[fix bug 1222137] Enable bedrock locale-based templates.
@pmclanahan r?