Marked relevant strings in python views/forms for translation via ugettext
This commit is contained in:
parent
03e5bd6d35
commit
4b1adc132c
@ -16,34 +16,36 @@
|
||||
|
||||
import wtforms
|
||||
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
|
||||
|
||||
class RegistrationForm(wtforms.Form):
|
||||
username = wtforms.TextField(
|
||||
'Username',
|
||||
_('Username'),
|
||||
[wtforms.validators.Required(),
|
||||
wtforms.validators.Length(min=3, max=30),
|
||||
wtforms.validators.Regexp(r'^\w+$')])
|
||||
password = wtforms.PasswordField(
|
||||
'Password',
|
||||
_('Password'),
|
||||
[wtforms.validators.Required(),
|
||||
wtforms.validators.Length(min=6, max=30),
|
||||
wtforms.validators.EqualTo(
|
||||
'confirm_password',
|
||||
'Passwords must match.')])
|
||||
_('Passwords must match.'))])
|
||||
confirm_password = wtforms.PasswordField(
|
||||
'Confirm password',
|
||||
_('Confirm password'),
|
||||
[wtforms.validators.Required()])
|
||||
email = wtforms.TextField(
|
||||
'Email address',
|
||||
_('Email address'),
|
||||
[wtforms.validators.Required(),
|
||||
wtforms.validators.Email()])
|
||||
|
||||
|
||||
class LoginForm(wtforms.Form):
|
||||
username = wtforms.TextField(
|
||||
'Username',
|
||||
_('Username'),
|
||||
[wtforms.validators.Required(),
|
||||
wtforms.validators.Regexp(r'^\w+$')])
|
||||
password = wtforms.PasswordField(
|
||||
'Password',
|
||||
_('Password'),
|
||||
[wtforms.validators.Required()])
|
||||
|
@ -21,6 +21,7 @@ from webob import exc
|
||||
from mediagoblin import messages
|
||||
from mediagoblin import mg_globals
|
||||
from mediagoblin.util import render_to_response, redirect
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
from mediagoblin.db.util import ObjectId
|
||||
from mediagoblin.auth import lib as auth_lib
|
||||
from mediagoblin.auth import forms as auth_forms
|
||||
@ -36,7 +37,7 @@ def register(request):
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.WARNING,
|
||||
('Sorry, registration is disabled on this instance.'))
|
||||
_('Sorry, registration is disabled on this instance.'))
|
||||
return redirect(request, "index")
|
||||
|
||||
register_form = auth_forms.RegistrationForm(request.POST)
|
||||
@ -51,7 +52,7 @@ def register(request):
|
||||
|
||||
if users_with_username:
|
||||
register_form.username.errors.append(
|
||||
u'Sorry, a user with that name already exists.')
|
||||
_(u'Sorry, a user with that name already exists.'))
|
||||
|
||||
else:
|
||||
# Create the user
|
||||
@ -148,12 +149,13 @@ def verify_email(request):
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.SUCCESS,
|
||||
('Your email address has been verified. '
|
||||
'You may now login, edit your profile, and submit images!'))
|
||||
_("Your email address has been verified. "
|
||||
"You may now login, edit your profile, and submit images!"))
|
||||
else:
|
||||
messages.add_message(request,
|
||||
messages.ERROR,
|
||||
'The verification key or user id is incorrect')
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.ERROR,
|
||||
_('The verification key or user id is incorrect'))
|
||||
|
||||
return redirect(
|
||||
request, 'mediagoblin.user_pages.user_home',
|
||||
@ -174,7 +176,7 @@ def resend_activation(request):
|
||||
messages.add_message(
|
||||
request,
|
||||
messages.INFO,
|
||||
'Resent your verification email.')
|
||||
_('Resent your verification email.'))
|
||||
return redirect(
|
||||
request, 'mediagoblin.user_pages.user_home',
|
||||
user=request.user['username'])
|
||||
|
@ -16,25 +16,28 @@
|
||||
|
||||
|
||||
import wtforms
|
||||
|
||||
from mediagoblin.util import tag_length_validator, TOO_LONG_TAG_WARNING
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
|
||||
|
||||
class EditForm(wtforms.Form):
|
||||
title = wtforms.TextField(
|
||||
'Title',
|
||||
_('Title'),
|
||||
[wtforms.validators.Length(min=0, max=500)])
|
||||
slug = wtforms.TextField(
|
||||
'Slug',
|
||||
[wtforms.validators.Required(message="The slug can't be empty")])
|
||||
_('Slug'),
|
||||
[wtforms.validators.Required(message=_("The slug can't be empty"))])
|
||||
description = wtforms.TextAreaField('Description of this work')
|
||||
tags = wtforms.TextField(
|
||||
'Tags',
|
||||
_('Tags'),
|
||||
[tag_length_validator])
|
||||
|
||||
class EditProfileForm(wtforms.Form):
|
||||
bio = wtforms.TextAreaField('Bio',
|
||||
bio = wtforms.TextAreaField(
|
||||
_('Bio'),
|
||||
[wtforms.validators.Length(min=0, max=500)])
|
||||
url = wtforms.TextField(
|
||||
'Website',
|
||||
_('Website'),
|
||||
[wtforms.validators.Optional(),
|
||||
wtforms.validators.URL(message='Improperly formed URL')])
|
||||
wtforms.validators.URL(message=_('Improperly formed URL'))])
|
||||
|
@ -23,6 +23,7 @@ from mediagoblin import mg_globals
|
||||
from mediagoblin.util import (
|
||||
render_to_response, redirect, clean_html, convert_to_tag_list_of_dicts,
|
||||
media_tags_as_string, cleaned_markdown_conversion)
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
from mediagoblin.edit import forms
|
||||
from mediagoblin.edit.lib import may_edit_media
|
||||
from mediagoblin.decorators import require_active_login, get_user_media_entry
|
||||
@ -50,7 +51,7 @@ def edit_media(request, media):
|
||||
|
||||
if existing_user_slug_entries:
|
||||
form.slug.errors.append(
|
||||
u'An entry with that slug already exists for this user.')
|
||||
_(u'An entry with that slug already exists for this user.'))
|
||||
else:
|
||||
media['title'] = request.POST['title']
|
||||
media['description'] = request.POST.get('description')
|
||||
@ -71,7 +72,7 @@ def edit_media(request, media):
|
||||
and request.method != 'POST':
|
||||
messages.add_message(
|
||||
request, messages.WARNING,
|
||||
"You are editing another user's media. Proceed with caution.")
|
||||
_("You are editing another user's media. Proceed with caution."))
|
||||
|
||||
|
||||
return render_to_response(
|
||||
@ -92,7 +93,7 @@ def edit_profile(request):
|
||||
if request.method != 'POST':
|
||||
messages.add_message(
|
||||
request, messages.WARNING,
|
||||
"You are editing a user's profile. Proceed with caution.")
|
||||
_("You are editing a user's profile. Proceed with caution."))
|
||||
else:
|
||||
user = request.user
|
||||
|
||||
|
@ -16,15 +16,17 @@
|
||||
|
||||
|
||||
import wtforms
|
||||
|
||||
from mediagoblin.util import tag_length_validator
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
|
||||
|
||||
class SubmitStartForm(wtforms.Form):
|
||||
title = wtforms.TextField(
|
||||
'Title',
|
||||
_('Title'),
|
||||
[wtforms.validators.Length(min=0, max=500)])
|
||||
description = wtforms.TextAreaField('Description of this work')
|
||||
file = wtforms.FileField('File')
|
||||
file = wtforms.FileField(_('File'))
|
||||
tags = wtforms.TextField(
|
||||
'Tags',
|
||||
_('Tags'),
|
||||
[tag_length_validator])
|
||||
|
@ -23,6 +23,7 @@ from werkzeug.utils import secure_filename
|
||||
from mediagoblin.util import (
|
||||
render_to_response, redirect, cleaned_markdown_conversion, \
|
||||
convert_to_tag_list_of_dicts)
|
||||
from mediagoblin.util import pass_to_ugettext as _
|
||||
from mediagoblin.decorators import require_active_login
|
||||
from mediagoblin.submit import forms as submit_forms, security
|
||||
from mediagoblin.process_media import process_media_initial
|
||||
@ -41,10 +42,10 @@ def submit_start(request):
|
||||
and isinstance(request.POST['file'], FieldStorage)
|
||||
and request.POST['file'].file):
|
||||
submit_form.file.errors.append(
|
||||
u'You must provide a file.')
|
||||
_(u'You must provide a file.'))
|
||||
elif not security.check_filetype(request.POST['file']):
|
||||
submit_form.file.errors.append(
|
||||
u'The file doesn\'t seem to be an image!')
|
||||
_(u"The file doesn't seem to be an image!"))
|
||||
else:
|
||||
filename = request.POST['file'].filename
|
||||
|
||||
@ -92,7 +93,7 @@ def submit_start(request):
|
||||
# queue it for processing
|
||||
process_media_initial.delay(unicode(entry['_id']))
|
||||
|
||||
add_message(request, SUCCESS, 'Woohoo! Submitted!')
|
||||
add_message(request, SUCCESS, _('Woohoo! Submitted!'))
|
||||
|
||||
return redirect(request, "mediagoblin.user_pages.user_home",
|
||||
user = request.user['username'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user