diff --git a/src/documents/models.py b/src/documents/models.py index 6395d66aa..2349dacd1 100755 --- a/src/documents/models.py +++ b/src/documents/models.py @@ -122,7 +122,6 @@ class DocumentType(MatchingModel): verbose_name_plural = _("document types") - class Document(models.Model): STORAGE_TYPE_UNENCRYPTED = "unencrypted" @@ -230,8 +229,8 @@ class Document(models.Model): class Meta: ordering = ("-created",) - verbose_name = _("Document") - verbose_name_plural = _("Documents") + verbose_name = _("document") + verbose_name_plural = _("documents") def __str__(self): created = datetime.date.isoformat(self.created) diff --git a/src/paperless_mail/admin.py b/src/paperless_mail/admin.py index 0440234b7..4c63c2b29 100644 --- a/src/paperless_mail/admin.py +++ b/src/paperless_mail/admin.py @@ -1,6 +1,8 @@ from django.contrib import admin from paperless_mail.models import MailAccount, MailRule +from django.utils.translation import gettext_lazy as _ + class MailAccountAdmin(admin.ModelAdmin): @@ -19,31 +21,31 @@ class MailRuleAdmin(admin.ModelAdmin): (None, { 'fields': ('name', 'order', 'account', 'folder') }), - ("Filter", { + (_("Filter"), { 'description': - "Paperless will only process mails that match ALL of the " - "filters given below.", + _("Paperless will only process mails that match ALL of the " + "filters given below."), 'fields': ('filter_from', 'filter_subject', 'filter_body', 'maximum_age') }), - ("Actions", { + (_("Actions"), { 'description': - "The action applied to the mail. This action is only " - "performed when documents were consumed from the mail. Mails " - "without attachments will remain entirely untouched.", + _("The action applied to the mail. This action is only " + "performed when documents were consumed from the mail. " + "Mails without attachments will remain entirely untouched."), 'fields': ( 'action', 'action_parameter') }), - ("Metadata", { + (_("Metadata"), { 'description': - "Assign metadata to documents consumed from this rule " - "automatically. If you do not assign tags, types or " - "correspondents here, paperless will still process all " - "matching rules that you have defined.", + _("Assign metadata to documents consumed from this rule " + "automatically. If you do not assign tags, types or " + "correspondents here, paperless will still process all " + "matching rules that you have defined."), "fields": ( 'assign_title_from', 'assign_tag', diff --git a/src/paperless_mail/models.py b/src/paperless_mail/models.py index aa1ac5684..d585d7c1c 100644 --- a/src/paperless_mail/models.py +++ b/src/paperless_mail/models.py @@ -2,6 +2,8 @@ from django.db import models import documents.models as document_models +from django.utils.translation import gettext_lazy as _ + class MailAccount(models.Model): @@ -10,29 +12,39 @@ class MailAccount(models.Model): IMAP_SECURITY_STARTTLS = 3 IMAP_SECURITY_OPTIONS = ( - (IMAP_SECURITY_NONE, "No encryption"), - (IMAP_SECURITY_SSL, "Use SSL"), - (IMAP_SECURITY_STARTTLS, "Use STARTTLS"), + (IMAP_SECURITY_NONE, _("No encryption")), + (IMAP_SECURITY_SSL, _("Use SSL")), + (IMAP_SECURITY_STARTTLS, _("Use STARTTLS")), ) - name = models.CharField(max_length=256, unique=True) + name = models.CharField( + _("name"), + max_length=256, unique=True) - imap_server = models.CharField(max_length=256) + imap_server = models.CharField( + _("imap server"), + max_length=256) imap_port = models.IntegerField( + _("imap port"), blank=True, null=True, - help_text="This is usually 143 for unencrypted and STARTTLS " - "connections, and 993 for SSL connections.") + help_text=_("This is usually 143 for unencrypted and STARTTLS " + "connections, and 993 for SSL connections.")) imap_security = models.PositiveIntegerField( + _("imap security"), choices=IMAP_SECURITY_OPTIONS, default=IMAP_SECURITY_SSL ) - username = models.CharField(max_length=256) + username = models.CharField( + _("username"), + max_length=256) - password = models.CharField(max_length=256) + password = models.CharField( + _("password"), + max_length=256) def __str__(self): return self.name @@ -46,18 +58,18 @@ class MailRule(models.Model): ACTION_FLAG = 4 ACTIONS = ( - (ACTION_MARK_READ, "Mark as read, don't process read mails"), - (ACTION_FLAG, "Flag the mail, don't process flagged mails"), - (ACTION_MOVE, "Move to specified folder"), - (ACTION_DELETE, "Delete"), + (ACTION_MARK_READ, _("Mark as read, don't process read mails")), + (ACTION_FLAG, _("Flag the mail, don't process flagged mails")), + (ACTION_MOVE, _("Move to specified folder")), + (ACTION_DELETE, _("Delete")), ) TITLE_FROM_SUBJECT = 1 TITLE_FROM_FILENAME = 2 TITLE_SELECTOR = ( - (TITLE_FROM_SUBJECT, "Use subject as title"), - (TITLE_FROM_FILENAME, "Use attachment filename as title") + (TITLE_FROM_SUBJECT, _("Use subject as title")), + (TITLE_FROM_FILENAME, _("Use attachment filename as title")) ) CORRESPONDENT_FROM_NOTHING = 1 @@ -67,47 +79,65 @@ class MailRule(models.Model): CORRESPONDENT_SELECTOR = ( (CORRESPONDENT_FROM_NOTHING, - "Do not assign a correspondent"), + _("Do not assign a correspondent")), (CORRESPONDENT_FROM_EMAIL, "Use mail address"), (CORRESPONDENT_FROM_NAME, - "Use name (or mail address if not available)"), + _("Use name (or mail address if not available)")), (CORRESPONDENT_FROM_CUSTOM, - "Use correspondent selected below") + _("Use correspondent selected below")) ) - name = models.CharField(max_length=256, unique=True) + name = models.CharField( + _("name"), + max_length=256, unique=True) - order = models.IntegerField(default=0) + order = models.IntegerField( + _("order"), + default=0) account = models.ForeignKey( MailAccount, related_name="rules", - on_delete=models.CASCADE + on_delete=models.CASCADE, + verbose_name=_("account") ) - folder = models.CharField(default='INBOX', max_length=256) + folder = models.CharField( + _("folder"), + default='INBOX', max_length=256) - filter_from = models.CharField(max_length=256, null=True, blank=True) - filter_subject = models.CharField(max_length=256, null=True, blank=True) - filter_body = models.CharField(max_length=256, null=True, blank=True) + filter_from = models.CharField( + _("filter from"), + max_length=256, null=True, blank=True) + filter_subject = models.CharField( + _("filter subject"), + max_length=256, null=True, blank=True) + filter_body = models.CharField( + _("filter body"), + max_length=256, null=True, blank=True) maximum_age = models.PositiveIntegerField( + _("maximum age"), default=30, - help_text="Specified in days.") + help_text=_("Specified in days.")) action = models.PositiveIntegerField( + _("action"), choices=ACTIONS, default=ACTION_MARK_READ, ) action_parameter = models.CharField( + _("action parameter"), max_length=256, blank=True, null=True, - help_text="Additional parameter for the action selected above, i.e., " - "the target folder of the move to folder action." + help_text=_("Additional parameter for the action selected above, " + "i.e., " + "the target folder of the move to folder action.") ) assign_title_from = models.PositiveIntegerField( + _("assign title from"), choices=TITLE_SELECTOR, default=TITLE_FROM_SUBJECT ) @@ -116,17 +146,20 @@ class MailRule(models.Model): document_models.Tag, null=True, blank=True, - on_delete=models.SET_NULL + on_delete=models.SET_NULL, + verbose_name=_("assign this tag"), ) assign_document_type = models.ForeignKey( document_models.DocumentType, null=True, blank=True, - on_delete=models.SET_NULL + on_delete=models.SET_NULL, + verbose_name=_("assign this document type"), ) assign_correspondent_from = models.PositiveIntegerField( + _("assign correspondent from"), choices=CORRESPONDENT_SELECTOR, default=CORRESPONDENT_FROM_NOTHING ) @@ -135,7 +168,8 @@ class MailRule(models.Model): document_models.Correspondent, null=True, blank=True, - on_delete=models.SET_NULL + on_delete=models.SET_NULL, + verbose_name=_("assign this correspondent") ) def __str__(self):