Anonymous avatar Anonymous committed f63f2ba Draft

Use ugettext for translating

Comments (0)

Files changed (3)

 # coding: utf-8
 from django import forms
+from django.utils.translation import ugettext as _
+from pybb.models import Post
-from pybb.models import Post
 class PostForm(forms.ModelForm):
     class Meta:
 class TopicForm(forms.Form):
-    name = forms.CharField(label=u'Название темы')
-    content = forms.CharField(label=u'Сообщение', widget=forms.Textarea)
+    name = forms.CharField(label=_(u'Название темы'))
+    content = forms.CharField(label=_(u'Сообщение'), widget=forms.Textarea)
 class TopicDeleteForm(forms.Form):
 from django.db import models
 from django.core.urlresolvers import reverse
+from django.utils.translation import ugettext as _
 class Category(models.Model):
     name = models.CharField(max_length=100)
 class Topic(models.Model):
-    name = models.CharField(u'Заголовок темы', max_length=100)
+    name = models.CharField(_(u'Заголовок темы'), max_length=100)
     created = models.DateTimeField(blank=True,
     forum = models.ForeignKey('pybb.Forum', related_name='topics')
     post_count = models.IntegerField(blank=True, default=0)
 class Post(models.Model):
     created = models.DateTimeField(blank=True,
     topic = models.ForeignKey('pybb.Topic', related_name='posts')
-    content = models.TextField(u'Сообщение')
+    content = models.TextField(_(u'Сообщение'))
     content_html = models.TextField(blank=True)
     user = models.ForeignKey('auth.User')
 from django.conf import settings
 from django.contrib.auth.decorators import login_required
 from django.contrib import messages
+from django.utils.translation import ugettext as _
 from common.pagination import paginate
 from pybb.models import Category, Forum, Topic, Post
-        messages.success(request, u'Обсуждение успешно создано')
+        messages.success(request, _(u'Обсуждение успешно создано'))
         return redirect(topic)
     context = {'form': form,
                'forum': forum,
 def topic_delete(request, pk):
     topic = get_object_or_404(Topic, pk=pk)
     if not request.user.is_superuser:
-        messages.error(request, u'У вас нет права на удаление темы')
+        messages.error(request, _(u'У вас нет права на удаление темы'))
         return reverse('pybb:home_page')
     if request.method == 'POST':
         form = TopicDeleteForm(request.POST)
         form = TopicDeleteForm()
     if form.is_valid():
-        messages.success(request, u'Тема удалена')
+        messages.success(request, _(u'Тема удалена'))
         return redirect('pybb:home_page')
     context = {'topic': topic, 'form': form,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.