make the message l10n-friendly

This commit is contained in:
Jeff Balogh 2011-01-12 18:27:13 -08:00
Родитель 62ce21d99b
Коммит e7a5c4ced4
3 изменённых файлов: 12 добавлений и 13 удалений

Просмотреть файл

@ -11,9 +11,9 @@ from tower import ugettext as _, ungettext as ngettext
import amo
import captcha.fields
from amo.utils import (ImageCheck, slug_validator, slugify, sorted_groupby,
remove_icons)
from addons.models import MiniAddon, Addon, ReverseNameLookup, Category, AddonCategory
from amo.utils import slug_validator, slugify, sorted_groupby, remove_icons
from addons.models import (Addon, AddonCategory, Category, MiniAddon,
ReverseNameLookup)
from addons.widgets import IconWidgetRenderer, CategoriesSelectMultiple
from applications.models import Application
from devhub import tasks
@ -95,11 +95,9 @@ class AddonFormBasic(AddonFormBase):
blacklisted.append(tag.tag_text)
if blacklisted:
# L10n: "{0} and {1}" displays tags as "a, b and c".
msg = ngettext("The tag '{1}' isn't allowed.",
"The tags '{0}' and '{1}' aren't allowed.",
len(blacklisted)).format("', '".join(blacklisted[:-1]),
blacklisted[-1])
# L10n: {0} is a single tag or a comma-separated list of tags.
msg = ngettext('Invalid tag: {0}', 'Invalid tags: {0}',
len(blacklisted)).format(', '.join(blacklisted))
raise forms.ValidationError(msg)
if total > max_tags:
@ -248,6 +246,7 @@ class AddonFormMedia(AddonFormBase):
return super(AddonFormMedia, self).save(commit)
class AddonFormDetails(AddonFormBase):
default_locale = forms.TypedChoiceField(choices=Addon.LOCALES)

Просмотреть файл

@ -9,7 +9,6 @@ from mock import patch
from redisutils import mock_redis, reset_redis
from addons import forms, cron
from addons import forms
from addons.models import Addon, Category
import amo
@ -155,6 +154,7 @@ class TestIconRemoval(test_utils.TestCase):
for path in self.get_icon_paths():
assert os.path.exists(path)
class TestUpdate(test_utils.TestCase):
fixtures = ['base/addon_3615',
'base/platforms',
@ -166,7 +166,7 @@ class TestUpdate(test_utils.TestCase):
'version': '2.0.58',
'reqVersion': 1,
'appID': '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}',
'appVersion': '3.7a1pre'
'appVersion': '3.7a1pre',
}
def test_beta(self):

Просмотреть файл

@ -1137,7 +1137,7 @@ class TestEdit(test_utils.TestCase):
r = self.client.post(self.get_url('basic', True), data)
eq_(r.status_code, 200)
error = "The tag 'blue' isn't allowed."
error = 'Invalid tag: blue'
self.assertFormError(r, 'form', 'tags', error)
def test_edit_basic_blacklisted_tags_2(self):
@ -1147,7 +1147,7 @@ class TestEdit(test_utils.TestCase):
r = self.client.post(self.get_url('basic', True), data)
eq_(r.status_code, 200)
error = "The tags 'blue' and 'darn' aren't allowed."
error = 'Invalid tags: blue, darn'
self.assertFormError(r, 'form', 'tags', error)
def test_edit_basic_blacklisted_tags_3(self):
@ -1158,7 +1158,7 @@ class TestEdit(test_utils.TestCase):
r = self.client.post(self.get_url('basic', True), data)
eq_(r.status_code, 200)
error = "The tags 'blue', 'darn' and 'swearword' aren't allowed."
error = 'Invalid tags: blue, darn, swearword'
self.assertFormError(r, 'form', 'tags', error)
def test_edit_basic_remove_tag(self):