summaryrefslogtreecommitdiffstats
path: root/forum
diff options
context:
space:
mode:
Diffstat (limited to 'forum')
-rw-r--r--forum/const.py74
-rw-r--r--forum/feed.py12
-rw-r--r--forum/forms.py87
-rw-r--r--forum/models.py9
-rw-r--r--forum/templatetags/extra_tags.py52
-rw-r--r--forum/user.py42
-rw-r--r--forum/views.py11
7 files changed, 148 insertions, 139 deletions
diff --git a/forum/const.py b/forum/const.py
index d285de7d..f6649cc4 100644
--- a/forum/const.py
+++ b/forum/const.py
@@ -1,18 +1,19 @@
-# encoding:utf-8
+# encoding:utf-8
+from django.utils.translation import ugettext as _
"""
All constants could be used in other modules
For reasons that models, views can't have unicode text in this project, all unicode text go here.
"""
CLOSE_REASONS = (
- (1, u'完全重复的问题'),
- (2, u'不是编程技术问题'),
- (3, u'太主观性、引起争吵的问题'),
- (4, u'不是一个可以回答的“问题”'),
- (5, u'问题已经解决,已得到正确答案'),
- (6, u'已经过时、不可重现的问题'),
- (7, u'太局部、本地化的问题'),
- (8, u'恶意言论'),
- (9, u'垃圾广告'),
+ (1, _('duplicate question')),
+ (2, _('question if off-topic or not relevant')),
+ (3, _('too subjective and argumentative')),
+ (4, _('is not an answer to the question')),
+ (5, _('the question is answered, right answer was accepted')),
+ (6, _('problem is not reproducible or outdated')),
+ #(7, u'太局部、本地化的问题',)
+ (7, _('question contains offensive inappropriate, or malicious remarks')),
+ (8, _('spam or advertising')),
)
TYPE_REPUTATION = (
@@ -52,38 +53,35 @@ TYPE_ACTIVITY_USER_FULL_UPDATED = 17
#TYPE_ACTIVITY_EDIT_ANSWER=18
TYPE_ACTIVITY = (
- (TYPE_ACTIVITY_ASK_QUESTION, u'提问'),
- (TYPE_ACTIVITY_ANSWER, u'回答'),
- (TYPE_ACTIVITY_COMMENT_QUESTION, u'评论问题'),
- (TYPE_ACTIVITY_COMMENT_ANSWER, u'评论回答'),
- (TYPE_ACTIVITY_UPDATE_QUESTION, u'修改问题'),
- (TYPE_ACTIVITY_UPDATE_ANSWER, u'修改回答'),
- (TYPE_ACTIVITY_PRIZE, u'获奖'),
- (TYPE_ACTIVITY_MARK_ANSWER, u'标记最佳答案'),
- (TYPE_ACTIVITY_VOTE_UP, u'投赞成票'),
- (TYPE_ACTIVITY_VOTE_DOWN, u'投反对票'),
- (TYPE_ACTIVITY_CANCEL_VOTE, u'撤销投票'),
- (TYPE_ACTIVITY_DELETE_QUESTION, u'删除问题'),
- (TYPE_ACTIVITY_DELETE_ANSWER, u'删除回答'),
- (TYPE_ACTIVITY_MARK_OFFENSIVE, u'标记垃圾帖'),
- (TYPE_ACTIVITY_UPDATE_TAGS, u'更新标签'),
- (TYPE_ACTIVITY_FAVORITE, u'收藏'),
- (TYPE_ACTIVITY_USER_FULL_UPDATED, u'完成个人所有资料'),
- #(TYPE_ACTIVITY_EDIT_QUESTION, u'编辑问题'),
- #(TYPE_ACTIVITY_EDIT_ANSWER, u'编辑答案'),
+ (TYPE_ACTIVITY_ASK_QUESTION, _('question')),
+ (TYPE_ACTIVITY_ANSWER, _('answer')),
+ (TYPE_ACTIVITY_COMMENT_QUESTION, _('commented question')),
+ (TYPE_ACTIVITY_COMMENT_ANSWER, _('commented answer')),
+ (TYPE_ACTIVITY_UPDATE_QUESTION, _('edited question')),
+ (TYPE_ACTIVITY_UPDATE_ANSWER, _('edited answer')),
+ (TYPE_ACTIVITY_PRIZE, _('received award')),
+ (TYPE_ACTIVITY_MARK_ANSWER, _('marked best answer')),
+ (TYPE_ACTIVITY_VOTE_UP, _('upvoted')),
+ (TYPE_ACTIVITY_VOTE_DOWN, _('downvoted')),
+ (TYPE_ACTIVITY_CANCEL_VOTE, _('canceled vote')),
+ (TYPE_ACTIVITY_DELETE_QUESTION, _('deleted question')),
+ (TYPE_ACTIVITY_DELETE_ANSWER, _('deleted answer')),
+ (TYPE_ACTIVITY_MARK_OFFENSIVE, _('marked offensive')),
+ (TYPE_ACTIVITY_UPDATE_TAGS, _('updated tags')),
+ (TYPE_ACTIVITY_FAVORITE, _('selected favorite')),
+ (TYPE_ACTIVITY_USER_FULL_UPDATED, _('completed user profile')),
)
TYPE_RESPONSE = {
- 'QUESTION_ANSWERED' : u'回答问题',
- 'QUESTION_COMMENTED': u'问题评论',
- 'ANSWER_COMMENTED' : u'回答评论',
- 'ANSWER_ACCEPTED' : u'最佳答案',
+ 'QUESTION_ANSWERED' : 'question_answered',
+ 'QUESTION_COMMENTED': 'question_commented',
+ 'ANSWER_COMMENTED' : 'answer_commented',
+ 'ANSWER_ACCEPTED' : 'answer_accepted',
}
CONST = {
- 'closed' : u' [已关闭]',
- 'deleted' : u' [已删除]',
- 'default_version' : u'初始版本',
- 'retagged' : u'更新了标签',
-
+ 'closed' : _('[closed]'),
+ 'deleted' : _('[deleted]'),
+ 'default_version' : _('initial version'),
+ 'retagged' : _('retagged'),
}
diff --git a/forum/feed.py b/forum/feed.py
index d75f3be6..a4218630 100644
--- a/forum/feed.py
+++ b/forum/feed.py
@@ -11,13 +11,15 @@
# Licence: GPL V2
#-------------------------------------------------------------------------------
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
+from django.utils.translation import ugettext as _
from models import Question
class RssLastestQuestionsFeed(Feed):
- title = u"CNProg程序员问答社区-最新问题"
- link = u"http://www.cnprog.com/questions/"
- description = u"中国程序员的编程技术问答社区。我们做专业的、可协作编辑的技术问答社区。"
+ title = _('site title') + _(' - ') + _('site slogan') + _(' - ')+ _('latest questions')
+ #EDIT!!!
+ link = 'http://where.com/questions/'
+ description = _('meta site content')
#ttl = 10
- copyright = u'Copyright(c)2009.CNPROG.COM'
+ copyright = _('copyright message')
def item_link(self, item):
return '/questions/%s/' % item.id
@@ -38,4 +40,4 @@ def main():
pass
if __name__ == '__main__':
- main() \ No newline at end of file
+ main()
diff --git a/forum/forms.py b/forum/forms.py
index 70a44f28..1b811ad9 100644
--- a/forum/forms.py
+++ b/forum/forms.py
@@ -1,8 +1,9 @@
-import re
+import re
from datetime import date
from django import forms
from models import *
from const import *
+from django.utils.translation import ugettext as _
class TitleField(forms.CharField):
def __init__(self, *args, **kwargs):
@@ -10,13 +11,13 @@ class TitleField(forms.CharField):
self.required = True
self.widget = forms.TextInput(attrs={'size' : 70, 'autocomplete' : 'off'})
self.max_length = 255
- self.label = u'标题'
- self.help_text = u'请输入对问题具有描述性质的标题 - “帮忙!紧急求助!”不是建议的提问方式。'
+ self.label = _('title')
+ self.help_text = _('please enter a descriptive title for your question')
self.initial = ''
def clean(self, value):
if len(value) < 10:
- raise forms.ValidationError(u"标题的长度必须大于10")
+ raise forms.ValidationError(_('title must be > 10 characters'))
return value
@@ -25,13 +26,13 @@ class EditorField(forms.CharField):
super(EditorField, self).__init__(*args, **kwargs)
self.required = True
self.widget = forms.Textarea(attrs={'id':'editor'})
- self.label = u'内容'
+ self.label = _('content')
self.help_text = u''
self.initial = ''
def clean(self, value):
if len(value) < 10:
- raise forms.ValidationError(u"内容至少要10个字符")
+ raise forms.ValidationError(_('question content must be > 10 characters'))
return value
@@ -41,39 +42,37 @@ class TagNamesField(forms.CharField):
self.required = True
self.widget = forms.TextInput(attrs={'size' : 50, 'autocomplete' : 'off'})
self.max_length = 255
- self.label = u'标签'
- self.help_text = u'多个标签请用空格间隔-最多5个标签。(优先使用自动匹配的英文标签。)'
+ self.label = _('tags')
+ self.help_text = _('please use space to separate tags (this enables autocomplete feature)')
self.initial = ''
- def clean(self, value):
- value = super(TagNamesField, self).clean(value)
- data = value.strip()
- if len(data) < 1:
- raise forms.ValidationError(u'标签不能为空')
- list = data.split(' ')
- list_temp = []
- if len(list) > 5:
- raise forms.ValidationError(u'最多只能有5个标签')
- for tag in list:
- if len(tag) > 20:
- raise forms.ValidationError(u'每个标签的长度不超过20')
-
- #TODO: regex match not allowed characters here
-
- if tag.find('/') > -1 or tag.find('\\') > -1 or tag.find('<') > -1 or tag.find('>') > -1 or tag.find('&') > -1 or tag.find('\'') > -1 or tag.find('"') > -1:
- #if not tagname_re.match(tag):
- raise forms.ValidationError(u'标签请使用英文字母,中文或者数字字符串(. - _ # 也可以)')
- # only keep one same tag
- if tag not in list_temp and len(tag.strip()) > 0:
- list_temp.append(tag)
- return u' '.join(list_temp)
+ def clean(self, value):
+ value = super(TagNamesField, self).clean(value)
+ data = value.strip()
+ if len(data) < 1:
+ raise forms.ValidationError(_('tags are required'))
+ list = data.split(' ')
+ list_temp = []
+ if len(list) > 5:
+ raise forms.ValidationError(_('please use 5 tags or less'))
+ for tag in list:
+ if len(tag) > 20:
+ raise forms.ValidationError(_('tags must be shorter than 20 characters'))
+ #take tag regex from settings
+ tagname_re = re.compile(r'[a-z0-9]+')
+ if not tagname_re.match(tag):
+ raise forms.ValidationError(_('please use following characters in tags: letters \'a-z\', numbers, and characters \'.-_#\''))
+ # only keep one same tag
+ if tag not in list_temp and len(tag.strip()) > 0:
+ list_temp.append(tag)
+ return u' '.join(list_temp)
class WikiField(forms.BooleanField):
def __init__(self, *args, **kwargs):
super(WikiField, self).__init__(*args, **kwargs)
self.required = False
- self.label = u'社区wiki模式'
- self.help_text = u'选择社区wiki模式,问答不计算积分,签名也不显示作者信息'
+ self.label = _('community wiki')
+ self.help_text = _('if you choose community wiki option, the question and answer do not generate points and name of author will not be shown')
class SummaryField(forms.CharField):
@@ -82,8 +81,8 @@ class SummaryField(forms.CharField):
self.required = False
self.widget = forms.TextInput(attrs={'size' : 50, 'autocomplete' : 'off'})
self.max_length = 300
- self.label = u'更新概要:'
- self.help_text = u'输入本次修改的简单概述(如:修改了别字,修正了语法,改进了样式等。非必填项。)'
+ self.label = _('update summary:')
+ self.help_text = _('enter a brief summary of your revision (e.g. fixed spelling, grammar, improved style, this field is optional)')
class AskForm(forms.Form):
title = TitleField()
@@ -158,12 +157,12 @@ class EditAnswerForm(forms.Form):
self.fields['text'].initial = revision.text
class EditUserForm(forms.Form):
- email = forms.EmailField(label=u'Email', help_text=u'不会公开,用于头像显示服务', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- realname = forms.CharField(label=u'真实姓名', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- website = forms.URLField(label=u'个人网站', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- city = forms.CharField(label=u'城市', required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
- birthday = forms.DateField(label=u'生日', help_text=u'不会公开,只会显示您的年龄,格式为:YYYY-MM-DD', required=True, widget=forms.TextInput(attrs={'size' : 35}))
- about = forms.CharField(label=u'个人简介', required=False, widget=forms.Textarea(attrs={'cols' : 60}))
+ email = forms.EmailField(label=u'Email', help_text=_('this email does not have to be linked to gravatar'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
+ realname = forms.CharField(label=_('Real name'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
+ website = forms.URLField(label=_('Website'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
+ city = forms.CharField(label=_('Location'), required=False, max_length=255, widget=forms.TextInput(attrs={'size' : 35}))
+ birthday = forms.DateField(label=_('Date of birth'), help_text=_('will not be shown, used to calculate age, format: YYYY-MM-DD'), required=False, widget=forms.TextInput(attrs={'size' : 35}))
+ about = forms.CharField(label=_('Profile'), required=False, widget=forms.Textarea(attrs={'cols' : 60}))
def __init__(self, user, *args, **kwargs):
super(EditUserForm, self).__init__(*args, **kwargs)
@@ -173,7 +172,7 @@ class EditUserForm(forms.Form):
self.fields['city'].initial = user.location
if user.date_of_birth is not None:
- self.fields['birthday'].initial = user.date_of_birth.date()
+ self.fields['birthday'].initial = user.date_of_birth
else:
self.fields['birthday'].initial = '1990-01-01'
self.fields['about'].initial = user.about
@@ -188,7 +187,7 @@ class EditUserForm(forms.Form):
except User.DoesNotExist:
return self.cleaned_data['email']
except User.MultipleObjectsReturned:
- raise forms.ValidationError(u'该电子邮件已被注册,请选择另一个再试。')
- raise forms.ValidationError("该电子邮件帐号已被注册,请选择另一个再试。")
+ raise forms.ValidationError(_('this email has already been registered, please use another one'))
+ raise forms.ValidationError(_('this email has already been registered, please use another one'))
else:
- return self.cleaned_data['email'] \ No newline at end of file
+ return self.cleaned_data['email']
diff --git a/forum/models.py b/forum/models.py
index 290c9d56..570db274 100644
--- a/forum/models.py
+++ b/forum/models.py
@@ -10,6 +10,7 @@ from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.template.defaultfilters import slugify
from django.db.models.signals import post_delete, post_save, pre_save
+from django.utils.translation import ugettext as _
import django.dispatch
from forum.managers import *
@@ -312,9 +313,9 @@ class Badge(models.Model):
SILVER = 2
BRONZE = 3
TYPE_CHOICES = (
- (GOLD, u'金牌'),
- (SILVER, u'银牌'),
- (BRONZE, u'铜牌'),
+ (GOLD, _('gold')),
+ (SILVER, _('silver')),
+ (BRONZE, _('bronze')),
)
name = models.CharField(max_length=50)
@@ -650,4 +651,4 @@ mark_offensive.connect(record_mark_offensive, sender=Question)
mark_offensive.connect(record_mark_offensive, sender=Answer)
tags_updated.connect(record_update_tags, sender=Question)
post_save.connect(record_favorite_question, sender=FavoriteQuestion)
-user_updated.connect(record_user_full_updated, sender=User) \ No newline at end of file
+user_updated.connect(record_user_full_updated, sender=User)
diff --git a/forum/templatetags/extra_tags.py b/forum/templatetags/extra_tags.py
index 7c53c2cb..1a4d3641 100644
--- a/forum/templatetags/extra_tags.py
+++ b/forum/templatetags/extra_tags.py
@@ -8,6 +8,7 @@ from django.utils.encoding import smart_unicode
from django.utils.safestring import mark_safe
from django.utils.timesince import timesince
from forum.const import *
+from django.utils.translation import ugettext as _
register = template.Library()
@@ -110,23 +111,23 @@ def cnprog_pagesize(context):
"pagesize" : context["pagesize"],
"is_paginated": context["is_paginated"]
}
-
+
@register.simple_tag
def get_score_badge(user):
- BADGE_TEMPLATE = '<span class="score" title="%(reputation)s用户积分">%(reputation)s</span>'
+ BADGE_TEMPLATE = '<span class="score" title="%(reputation)s %(reputationword)s">%(reputation)s</span>'
if user.gold > 0 :
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' <span title="%(gold)s枚金牌">'
- '<span class="badge1">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(gold)s %(badgesword)s">'
+ '<span class="badge1">&#9679;</span>'
'<span class="badgecount">%(gold)s</span>'
'</span>')
if user.silver > 0:
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' <span title="%(silver)s枚银牌">'
- '<span class="silver">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(silver)s %(badgesword)s">'
+ '<span class="silver">&#9679;</span>'
'<span class="badgecount">%(silver)s</span>'
'</span>')
if user.bronze > 0:
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, ' <span title="%(bronze)s枚铜牌">'
- '<span class="bronze">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(bronze)s %(badgesword)s">'
+ '<span class="bronze">&#9679;</span>'
'<span class="badgecount">%(bronze)s</span>'
'</span>')
BADGE_TEMPLATE = smart_unicode(BADGE_TEMPLATE, encoding='utf-8', strings_only=False, errors='strict')
@@ -135,24 +136,26 @@ def get_score_badge(user):
'gold' : user.gold,
'silver' : user.silver,
'bronze' : user.bronze,
+ 'badgesword' : _('badges'),
+ 'reputationword' : _('reputation points'),
})
-
+
@register.simple_tag
def get_score_badge_by_details(rep, gold, silver, bronze):
- BADGE_TEMPLATE = '<span class="reputation-score" title="%(reputation)s用户积分">%(reputation)s</span>'
+ BADGE_TEMPLATE = '<span class="reputation-score" title="%(reputation)s %(repword)s">%(reputation)s</span>'
if gold > 0 :
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(gold)s枚金牌">'
- '<span class="badge1">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(gold)s %(badgeword)s">'
+ '<span class="badge1">&#9679;</span>'
'<span class="badgecount">%(gold)s</span>'
'</span>')
if silver > 0:
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(silver)s枚银牌">'
- '<span class="badge2">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(silver)s %(badgeword)s">'
+ '<span class="badge2">&#9679;</span>'
'<span class="badgecount">%(silver)s</span>'
'</span>')
if bronze > 0:
- BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(bronze)s枚铜牌">'
- '<span class="badge3">●</span>'
+ BADGE_TEMPLATE = '%s%s' % (BADGE_TEMPLATE, '<span title="%(bronze)s %(badgeword)s">'
+ '<span class="badge3">&#9679;</span>'
'<span class="badgecount">%(bronze)s</span>'
'</span>')
BADGE_TEMPLATE = smart_unicode(BADGE_TEMPLATE, encoding='utf-8', strings_only=False, errors='strict')
@@ -161,19 +164,24 @@ def get_score_badge_by_details(rep, gold, silver, bronze):
'gold' : gold,
'silver' : silver,
'bronze' : bronze,
- })
-
+ 'repword' : _('reputation points'),
+ 'badgeword' : _('badges'),
+ })
+
@register.simple_tag
def get_user_vote_image(dic, key, arrow):
if dic.has_key(key):
if int(dic[key]) == int(arrow):
return '-on'
return ''
-
+
@register.simple_tag
def get_age(birthday):
current_time = datetime.datetime(*time.localtime()[0:6])
- diff = current_time - birthday
+ year = birthday.year
+ month = birthday.month
+ day = birthday.day
+ diff = current_time - datetime.datetime(year,month,day,0,0,0)
return diff.days / 365
@register.simple_tag
@@ -210,8 +218,8 @@ def diff_date(date, limen=2):
if diff_days > limen:
return date
else:
- return timesince(date) + u'前'
-
+ return timesince(date) + _(' ago')
+
@register.simple_tag
def get_latest_changed_timestamp():
try:
diff --git a/forum/user.py b/forum/user.py
index 2461e073..233baf0c 100644
--- a/forum/user.py
+++ b/forum/user.py
@@ -14,61 +14,61 @@ class UserView:
USER_TEMPLATE_VIEWS = (
UserView(
id = 'stats',
- tab_title = _("Overview"),
- tab_description = _('User overview'),
- page_title = _('Overview - User Profile'),
+ tab_title = _('overview'),
+ tab_description = _('user profile'),
+ page_title = _('user profile overview'),
view_name = 'user_stats',
template_file = 'user_stats.html'
),
UserView(
id = 'recent',
- tab_title = _('Recent'),
- tab_description = _("Recent activities"),
- page_title = _('Recent - User Profile'),
+ tab_title = _('recent activity'),
+ tab_description = _('recent user activity'),
+ page_title = _('profile - recent activity'),
view_name = 'user_recent',
template_file = 'user_recent.html',
data_size = 50
),
UserView(
id = 'responses',
- tab_title = _("Response"),
- tab_description = _("Responses from others"),
- page_title = _("Response - User Profile"),
+ tab_title = _('responses'),
+ tab_description = _('comments and answers to others questions'),
+ page_title = _('profile - responses'),
view_name = 'user_responses',
template_file = 'user_responses.html',
data_size = 50
),
UserView(
id = 'reputation',
- tab_title = _("Reputation"),
- tab_description = _("Community reputation"),
- page_title = _("Reputation - User Profile"),
+ tab_title = _('reputation'),
+ tab_description = _('user reputation in the community'),
+ page_title = _('profile - user reputation'),
view_name = 'user_reputation',
template_file = 'user_reputation.html'
),
UserView(
id = 'favorites',
- tab_title = _("Favorites"),
- tab_description = _("User's favorite questions"),
- page_title = _("Favorites - User Profile"),
+ tab_title = _('favorite questions'),
+ tab_description = _('users favorite questions'),
+ page_title = _('profile - favorite questions'),
view_name = 'user_favorites',
template_file = 'user_favorites.html',
data_size = 50
),
UserView(
id = 'votes',
- tab_title = _("Votes"),
- tab_description = _("Votes history"),
- page_title = _("Votes - User Profile"),
+ tab_title = _('casted votes'),
+ tab_description = _('user vote record'),
+ page_title = _('profile - votes'),
view_name = 'user_votes',
template_file = 'user_votes.html',
data_size = 50
),
UserView(
id = 'preferences',
- tab_title = _("Preferences"),
- tab_description = _("User preferences"),
- page_title = _("Preferences - User Profile"),
+ tab_title = _('preferences'),
+ tab_description = _('user preference settings'),
+ page_title = _('profile - user preferences'),
view_name = 'user_preferences',
template_file = 'user_preferences.html'
)
diff --git a/forum/views.py b/forum/views.py
index 8252304e..08a0e958 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -15,6 +15,7 @@ from django.utils import simplejson
from django.core import serializers
from django.db import transaction
from django.contrib.contenttypes.models import ContentType
+from django.utils.translation import ugettext as _
from utils.html import sanitize_html
from markdown2 import Markdown
@@ -1722,13 +1723,13 @@ def upload(request):
result = xml_template % ('Good', '', default_storage.url(new_file_name))
except UploadPermissionNotAuthorized:
- result = xml_template % ('', u"上传图片只限于积分+60以上注册用户!", '')
+ result = xml_template % ('', _('uploading images is limited to users with >60 reputation points'), '')
except FileTypeNotAllow:
- result = xml_template % ('', u"只允许上传'jpg', 'jpeg', 'gif', 'bmp', 'png', 'tiff'类型的文件!", '')
+ result = xml_template % ('', _("allowed file types are 'jpg', 'jpeg', 'gif', 'bmp', 'png', 'tiff'"), '')
except FileSizeNotAllow:
- result = xml_template % ('', u"只允许上传%sK大小的文件!" % settings.ALLOW_MAX_FILE_SIZE / 1024, '')
- except Exception:
- result = xml_template % ('', u"在文件上传过程中产生了错误,请联系管理员,谢谢^_^", '')
+ result = xml_template % ('', _("maximum upload file size is %sK") % settings.ALLOW_MAX_FILE_SIZE / 1024, '')
+ except Exception as e:
+ result = xml_template % ('', _('Error uploading file. Please contact the site administrator. Thank you. %s' % e), '')
return HttpResponse(result, mimetype="application/xml")