Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Fixed category localizers to always be en-us (bug 719641)
Browse files Browse the repository at this point in the history
  • Loading branch information
robhudson committed Feb 6, 2012
1 parent 81ac985 commit 947a7c0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps/localizers/tests/test_views.py
Expand Up @@ -88,6 +88,18 @@ def test_the_basics(self):
doc = pq(res.content.decode('utf-8'))
eq_(doc('#id_form-0-name').val(), u'Campañas')

def test_other_local(self):
# Test that somethign other than /en-US/ as the site locale doesn't
# affect the left hand column category names.
with self.activate(locale='es-ES'):
url = reverse('localizers.categories',
kwargs=dict(locale_code='es-ES'))
res = self.client.get(url)
eq_(res.status_code, 200)
doc = pq(res.content.decode('utf-8'))
eq_(doc('#id_form-0-name').val(), u'Campañas')
eq_(doc('td.enus').eq(0).text(), u'Causes')

def test_post(self):
assert self.client.login(username='admin@mozilla.com',
password='password')
Expand Down
4 changes: 4 additions & 0 deletions apps/localizers/views.py
Expand Up @@ -3,6 +3,7 @@
from django import http
from django.conf import settings
from django.shortcuts import redirect
from django.utils import translation

import commonware.log
import jingo
Expand Down Expand Up @@ -106,7 +107,10 @@ def categories(request, locale_code):
if not _permission_to_edit_locale(request, locale_code):
return http.HttpResponseForbidden()

translation.activate('en-US')
cats = list(Category.objects.order_by('application'))
translation.deactivate()

strings = dict(Translation.objects.filter(
id__in=[c.name_id for c in cats], locale=locale_code)
.values_list('id', 'localized_string'))
Expand Down

0 comments on commit 947a7c0

Please sign in to comment.