Commits

Anonymous committed f63f2ba

Use ugettext for translating

  • Participants
  • Parent commits 1ccc7f9

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, default=datetime.now)
     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, default=datetime.now)
     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
             user=request.user,
             content=form.cleaned_data['content'],
         )
-        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():
         topic.delete()
-        messages.success(request, u'Тема удалена')
+        messages.success(request, _(u'Тема удалена'))
         return redirect('pybb:home_page')
     context = {'topic': topic, 'form': form,
             }