Skip to content

Commit

Permalink
merge Evgeny's English and Botum's Spanish translations
Browse files Browse the repository at this point in the history
  • Loading branch information
chagel committed Jul 28, 2009
1 parent 0173b3d commit b6aa7c8
Show file tree
Hide file tree
Showing 65 changed files with 7,773 additions and 1,083 deletions.
31 changes: 30 additions & 1 deletion development.log
@@ -1 +1,30 @@
# development log
# development

==July 26 2009, Evgeny==

django_authopenid:
considerably changed user interface

log/forum/forms.py:
- added tag input validation using regex
- fixed bug with date type mismatch near self.fields['birthday'] =
in EditUserForm.__init__()

/forum/templatetags/extra_tags.py:
- fixed date type mismatch in get_age()

/templates/content/js/com.cnprog.post.js:
- fixed bug with post deletion/recovery

javascript:
- changed to use of non-minified code - better for editing
and debugging

/templates/question.html:
- fixed display of delete/undelete links

templates:
added comments in the beginning/end of each template
for the debugging purposes - so that you know which template outputs what html
<!-- user_favorites.html -->
<!-- end user_favorites.html -->
18 changes: 9 additions & 9 deletions django_authopenid/forms.py
Expand Up @@ -155,20 +155,20 @@ def clean_username(self):
""" test if username is valid and exist in database """
if 'username' in self.cleaned_data:
if not username_re.search(self.cleaned_data['username']):
raise forms.ValidationError(u"用户名只能包含英文字母、数字和下划线")
raise forms.ValidationError(_('invalid user name'))
if self.cleaned_data['username'] in RESERVED_NAMES:
raise forms.ValidationError(u'对不起,您不能注册该用户名,请换一个试试')
raise forms.ValidationError(_('sorry, this name can not be used, please try another'))
if len(self.cleaned_data['username']) < 3:
raise forms.ValidationError(u'用户名太短,请使用三个或三个以上字符')
raise forms.ValidationError(_('username too short'))
try:
user = User.objects.get(
username__exact = self.cleaned_data['username']
)
except User.DoesNotExist:
return self.cleaned_data['username']
except User.MultipleObjectsReturned:
raise forms.ValidationError(u'该用户名已被注册,请换一个试试')
raise forms.ValidationError(u'该用户名已被注册,请换个试试')
raise forms.ValidationError(_('this name is already in use - please try anoter'))
raise forms.ValidationError(_('this name is already in use - please try anoter'))

def clean_email(self):
"""For security reason one unique email in database"""
Expand Down Expand Up @@ -250,13 +250,13 @@ class RegistrationForm(forms.Form):
required=False)
username = forms.CharField(max_length=30,
widget=forms.TextInput(attrs=attrs_dict),
label=u'Username')
label=_('choose a username'))
email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
maxlength=200)), label=u'Email address')
maxlength=200)), label=_('your email address'))
password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict),
label=u'Password')
label=_('choose password'))
password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict),
label=u'Password (again, to catch typos)')
label=_('retype password'))

def clean_username(self):
"""
Expand Down
74 changes: 36 additions & 38 deletions 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 = (
Expand Down Expand Up @@ -52,38 +53,35 @@
#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'),
}
12 changes: 7 additions & 5 deletions forum/feed.py
Expand Up @@ -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
Expand All @@ -38,4 +40,4 @@ def main():
pass

if __name__ == '__main__':
main()
main()
87 changes: 43 additions & 44 deletions forum/forms.py
@@ -1,22 +1,23 @@
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):
super(TitleField, self).__init__(*args, **kwargs)
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

Expand All @@ -25,13 +26,13 @@ def __init__(self, *args, **kwargs):
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

Expand All @@ -41,39 +42,37 @@ def __init__(self, *args, **kwargs):
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):
Expand All @@ -82,8 +81,8 @@ def __init__(self, *args, **kwargs):
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()
Expand Down Expand Up @@ -158,12 +157,12 @@ def __init__(self, answer, revision, *args, **kwargs):
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)
Expand All @@ -173,7 +172,7 @@ def __init__(self, user, *args, **kwargs):
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
Expand All @@ -188,7 +187,7 @@ def clean_email(self):
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']
return self.cleaned_data['email']
9 changes: 5 additions & 4 deletions forum/models.py
Expand Up @@ -10,6 +10,7 @@
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 *
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -650,4 +651,4 @@ def record_user_full_updated(instance, **kwargs):
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)
user_updated.connect(record_user_full_updated, sender=User)

0 comments on commit b6aa7c8

Please sign in to comment.