Marked relevant strings in python views/forms for translation via ugettext
authorChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 9 Aug 2011 03:53:39 +0000 (22:53 -0500)
committerChristopher Allan Webber <cwebber@dustycloud.org>
Tue, 9 Aug 2011 03:53:39 +0000 (22:53 -0500)
mediagoblin/auth/forms.py
mediagoblin/auth/views.py
mediagoblin/edit/forms.py
mediagoblin/edit/views.py
mediagoblin/submit/forms.py
mediagoblin/submit/views.py

index 7bc0aeb1325bef118ca83b9107bad7ecb3b876b2..1b6bc7c2851d66aadf1c404d356bd3760440c896 100644 (file)
 
 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()])
index df7e2a88c64d120c3c47f8754e01ce2ec86c1d3f..121a8c8e0783840fa49e032d59035353042952c0 100644 (file)
@@ -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'])
index a1783a726f6e0b1b7e7435dc20dda54169b7a98b..8052f482108d0f5b1d4217d80d5fb9a03134522b 100644 (file)
 
 
 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'))])
index 5cbaadb5e52cf68482b9ab1641aa3e85e1c59e04..0b1a98f1d6617fb89b1adc4fc810b0ed28b7695d 100644 (file)
@@ -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
 
index f02c95a69f970e6ef47a0aa76f00bc8195f7ce3b..ccb62a036cd408e0de17cbdd6ada3d7e0859c9c1 100644 (file)
 
 
 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])
index 87e57ddab2321157871d4f11ce8ba456a959bc55..ba13b755ce12f5a811d9a3fcd2af5c57ea9152d5 100644 (file)
@@ -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'])