From 4b1adc132cf45507e2f910122992230d428c6856 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 8 Aug 2011 22:53:39 -0500 Subject: [PATCH] Marked relevant strings in python views/forms for translation via ugettext --- mediagoblin/auth/forms.py | 16 +++++++++------- mediagoblin/auth/views.py | 18 ++++++++++-------- mediagoblin/edit/forms.py | 17 ++++++++++------- mediagoblin/edit/views.py | 7 ++++--- mediagoblin/submit/forms.py | 8 +++++--- mediagoblin/submit/views.py | 7 ++++--- 6 files changed, 42 insertions(+), 31 deletions(-) diff --git a/mediagoblin/auth/forms.py b/mediagoblin/auth/forms.py index 7bc0aeb1..1b6bc7c2 100644 --- a/mediagoblin/auth/forms.py +++ b/mediagoblin/auth/forms.py @@ -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()]) diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py index df7e2a88..121a8c8e 100644 --- a/mediagoblin/auth/views.py +++ b/mediagoblin/auth/views.py @@ -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']) diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py index a1783a72..8052f482 100644 --- a/mediagoblin/edit/forms.py +++ b/mediagoblin/edit/forms.py @@ -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'))]) diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index 5cbaadb5..0b1a98f1 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -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 diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py index f02c95a6..ccb62a03 100644 --- a/mediagoblin/submit/forms.py +++ b/mediagoblin/submit/forms.py @@ -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]) diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index 87e57dda..ba13b755 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -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']) -- 2.25.1