Skip to content

Commit

Permalink
Make models translatable and add Russian translation (#162)
Browse files Browse the repository at this point in the history
* Make models translatable

* Add Russian translation

* Fixed translation location

* Replace deprecated ugettext_lazy with gettext_lazy
  • Loading branch information
Real-Gecko authored Oct 2, 2020
1 parent cd9e751 commit 51954e0
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 36 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ coverage.xml
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
Expand Down
2 changes: 1 addition & 1 deletion easyaudit/admin_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.core.urlresolvers import reverse

from django.http import HttpResponseRedirect, HttpResponse
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib import messages
from django.conf.urls import url
from django.utils.safestring import mark_safe
Expand Down
Binary file added easyaudit/locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
191 changes: 191 additions & 0 deletions easyaudit/locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-28 18:11+0600\n"
"PO-Revision-Date: 2020-09-28 18:19+0600\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
"%10<=4 && (n%100<12 || n%100>14) ? 1 : n%10==0 || (n%10>=5 && n%10<=9) || (n"
"%100>=11 && n%100<=14)? 2 : 3);\n"
"Last-Translator: \n"
"Language-Team: \n"
"X-Generator: Poedit 2.4.1\n"

#: admin_helpers.py:122
#, python-format
msgid "Successfully removed %d rows"
msgstr "%d строк успешно удалено"

#: admin_helpers.py:124
msgid "ERROR"
msgstr "ОШИБКА"

#: admin_helpers.py:126
msgid "Action cancelled by user"
msgstr "Действие отменено пользователем"

#: admin_helpers.py:130
#, python-format
msgid "Purge all %s ... are you sure?"
msgstr "Удалить все %s ... вы уверены?"

#: models.py:15
msgid "Create"
msgstr "Создание"

#: models.py:16
msgid "Update"
msgstr "Обновление"

#: models.py:17
msgid "Delete"
msgstr "Удаление"

#: models.py:18
msgid "Many-to-Many Change"
msgstr "Изменение многие ко многим"

#: models.py:19
msgid "Reverse Many-to-Many Change"
msgstr "Изменение обратного многие ко многим"

#: models.py:22 models.py:60
msgid "Event type"
msgstr "Тип события"

#: models.py:23
msgid "Object ID"
msgstr "ID объекта"

#: models.py:24
msgid "Content type"
msgstr "Тип содержимого"

#: models.py:25
msgid "Object representation"
msgstr "Представление объекта"

#: models.py:26
msgid "Object JSON representation"
msgstr "JSON представление объекта"

#: models.py:27
msgid "Changed fields"
msgstr "Изменившиеся поля"

#: models.py:30 models.py:64 models.py:80
msgid "User"
msgstr "Пользователь"

#: models.py:32
msgid "String version of the user pk"
msgstr "Строковая версия ПК пользователя"

#: models.py:32
msgid "User PK as string"
msgstr "ПК пользователя как строка"

#: models.py:33 models.py:66 models.py:82
msgid "Date time"
msgstr "Дата время"

#: models.py:45
msgid "CRUD event"
msgstr "CRUD событие"

#: models.py:46
msgid "CRUD events"
msgstr "CRUD события"

#: models.py:56
msgid "Login"
msgstr "Вход"

#: models.py:57
msgid "Logout"
msgstr "Выход"

#: models.py:58
msgid "Failed login"
msgstr "Неудачная попытка входа"

#: models.py:61
msgid "Username"
msgstr "Имя пользователя"

#: models.py:65 models.py:81
msgid "Remote IP"
msgstr "Удаленный IP"

#: models.py:69
msgid "login event"
msgstr "событие входа"

#: models.py:70
msgid "login events"
msgstr "События входа"

#: models.py:75
msgid "URL"
msgstr "Адрес"

#: models.py:76
msgid "Method"
msgstr "Метод"

#: models.py:77
msgid "Query string"
msgstr "Запрос"

#: models.py:85
msgid "request event"
msgstr "Событие запроса"

#: models.py:86
msgid "request events"
msgstr "События запроса"

#: templates/admin/easyaudit/change_list.html:10
#, python-format
msgid "Purge %(name)s"
msgstr "Удалить %(name)s"

#: templates/admin/easyaudit/purge_confirmation.html:7
msgid "Home"
msgstr "Домой"

#: templates/admin/easyaudit/purge_confirmation.html:10
msgid "Purge"
msgstr "Удалить"

#: templates/admin/easyaudit/purge_confirmation.html:19
msgid "Please confirm deletion"
msgstr "Подтвердите удаление"

#: templates/admin/easyaudit/purge_confirmation.html:20
msgid ""
"This operation is destructive, cannot be undone and may require some minutes."
msgstr ""
"Эта операция удаляет данные, не может быть отменена и потребует несколько "
"минут."

#: templates/admin/easyaudit/purge_confirmation.html:21
msgid "Are you sure you want to permanently remove all objects ?"
msgstr "Вы уверены, что хотите удалить все объекты?"

#: templates/admin/easyaudit/purge_confirmation.html:25
msgid "Yes, I\\"
msgstr "Да, я\\"

#: templates/admin/easyaudit/purge_confirmation.html:26
msgid "Cancel"
msgstr "Отменить"
71 changes: 37 additions & 34 deletions easyaudit/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.translation import gettext_lazy as _


class CRUDEvent(models.Model):
Expand All @@ -11,25 +12,25 @@ class CRUDEvent(models.Model):
M2M_CHANGE_REV = 5

TYPES = (
(CREATE, 'Create'),
(UPDATE, 'Update'),
(DELETE, 'Delete'),
(M2M_CHANGE, 'Many-to-Many Change'),
(M2M_CHANGE_REV, 'Reverse Many-to-Many Change'),
(CREATE, _('Create')),
(UPDATE, _('Update')),
(DELETE, _('Delete')),
(M2M_CHANGE, _('Many-to-Many Change')),
(M2M_CHANGE_REV, _('Reverse Many-to-Many Change')),
)

event_type = models.SmallIntegerField(choices=TYPES)
object_id = models.CharField(max_length=255)
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, db_constraint=False)
object_repr = models.TextField(null=True, blank=True)
object_json_repr = models.TextField(null=True, blank=True)
changed_fields = models.TextField(null=True, blank=True)
event_type = models.SmallIntegerField(choices=TYPES, verbose_name=_('Event type'))
object_id = models.CharField(max_length=255, verbose_name=_('Object ID'))
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, db_constraint=False, verbose_name=_('Content type'))
object_repr = models.TextField(null=True, blank=True, verbose_name=_('Object representation'))
object_json_repr = models.TextField(null=True, blank=True, verbose_name=_('Object JSON representation'))
changed_fields = models.TextField(null=True, blank=True, verbose_name=_('Changed fields'))
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True,
blank=True, on_delete=models.SET_NULL,
db_constraint=False)
db_constraint=False, verbose_name=_('User'))
user_pk_as_string = models.CharField(max_length=255, null=True, blank=True,
help_text='String version of the user pk')
datetime = models.DateTimeField(auto_now_add=True)
help_text=_('String version of the user pk'), verbose_name=_('User PK as string'))
datetime = models.DateTimeField(auto_now_add=True, verbose_name=_('Date time'))

def is_create(self):
return self.CREATE == self.event_type
Expand All @@ -41,8 +42,8 @@ def is_delete(self):
return self.DELETE == self.event_type

class Meta:
verbose_name = 'CRUD event'
verbose_name_plural = 'CRUD events'
verbose_name = _('CRUD event')
verbose_name_plural = _('CRUD events')
ordering = ['-datetime']
index_together = ['object_id', 'content_type', ]

Expand All @@ -52,33 +53,35 @@ class LoginEvent(models.Model):
LOGOUT = 1
FAILED = 2
TYPES = (
(LOGIN, 'Login'),
(LOGOUT, 'Logout'),
(FAILED, 'Failed login'),
(LOGIN, _('Login')),
(LOGOUT, _('Logout')),
(FAILED, _('Failed login')),
)
login_type = models.SmallIntegerField(choices=TYPES)
username = models.CharField(max_length=255, null=True, blank=True)
login_type = models.SmallIntegerField(choices=TYPES, verbose_name=_('Event type'))
username = models.CharField(max_length=255, null=True, blank=True, verbose_name=_('Username'))
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,
on_delete=models.SET_NULL, db_constraint=False)
remote_ip = models.CharField(max_length=50, null=True, db_index=True)
datetime = models.DateTimeField(auto_now_add=True)
on_delete=models.SET_NULL, db_constraint=False,
verbose_name=_('User'))
remote_ip = models.CharField(max_length=50, null=True, db_index=True, verbose_name=_('Remote IP'))
datetime = models.DateTimeField(auto_now_add=True, verbose_name=_('Date time'))

class Meta:
verbose_name = 'login event'
verbose_name_plural = 'login events'
verbose_name = _('login event')
verbose_name_plural = _('login events')
ordering = ['-datetime']


class RequestEvent(models.Model):
url = models.CharField(null=False, db_index=True, max_length=254)
method = models.CharField(max_length=20, null=False, db_index=True)
query_string = models.TextField(null=True)
url = models.CharField(null=False, db_index=True, max_length=254, verbose_name=_('URL'))
method = models.CharField(max_length=20, null=False, db_index=True, verbose_name=_('Method'))
query_string = models.TextField(null=True, verbose_name=_('Query string'))
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, blank=True,
on_delete=models.SET_NULL, db_constraint=False)
remote_ip = models.CharField(max_length=50, null=True, db_index=True)
datetime = models.DateTimeField(auto_now_add=True)
on_delete=models.SET_NULL, db_constraint=False,
verbose_name=_('User'))
remote_ip = models.CharField(max_length=50, null=True, db_index=True, verbose_name=_('Remote IP'))
datetime = models.DateTimeField(auto_now_add=True, verbose_name=_('Date time'))

class Meta:
verbose_name = 'request event'
verbose_name_plural = 'request events'
verbose_name = _('request event')
verbose_name_plural = _('request events')
ordering = ['-datetime']

0 comments on commit 51954e0

Please sign in to comment.