more translation

This commit is contained in:
jonaswinkler 2020-12-31 15:59:12 +01:00
parent 750d08ec01
commit fddda75f75
3 changed files with 81 additions and 46 deletions

View File

@ -122,7 +122,6 @@ class DocumentType(MatchingModel):
verbose_name_plural = _("document types") verbose_name_plural = _("document types")
class Document(models.Model): class Document(models.Model):
STORAGE_TYPE_UNENCRYPTED = "unencrypted" STORAGE_TYPE_UNENCRYPTED = "unencrypted"
@ -230,8 +229,8 @@ class Document(models.Model):
class Meta: class Meta:
ordering = ("-created",) ordering = ("-created",)
verbose_name = _("Document") verbose_name = _("document")
verbose_name_plural = _("Documents") verbose_name_plural = _("documents")
def __str__(self): def __str__(self):
created = datetime.date.isoformat(self.created) created = datetime.date.isoformat(self.created)

View File

@ -1,6 +1,8 @@
from django.contrib import admin from django.contrib import admin
from paperless_mail.models import MailAccount, MailRule from paperless_mail.models import MailAccount, MailRule
from django.utils.translation import gettext_lazy as _
class MailAccountAdmin(admin.ModelAdmin): class MailAccountAdmin(admin.ModelAdmin):
@ -19,31 +21,31 @@ class MailRuleAdmin(admin.ModelAdmin):
(None, { (None, {
'fields': ('name', 'order', 'account', 'folder') 'fields': ('name', 'order', 'account', 'folder')
}), }),
("Filter", { (_("Filter"), {
'description': 'description':
"Paperless will only process mails that match ALL of the " _("Paperless will only process mails that match ALL of the "
"filters given below.", "filters given below."),
'fields': 'fields':
('filter_from', ('filter_from',
'filter_subject', 'filter_subject',
'filter_body', 'filter_body',
'maximum_age') 'maximum_age')
}), }),
("Actions", { (_("Actions"), {
'description': 'description':
"The action applied to the mail. This action is only " _("The action applied to the mail. This action is only "
"performed when documents were consumed from the mail. Mails " "performed when documents were consumed from the mail. "
"without attachments will remain entirely untouched.", "Mails without attachments will remain entirely untouched."),
'fields': ( 'fields': (
'action', 'action',
'action_parameter') 'action_parameter')
}), }),
("Metadata", { (_("Metadata"), {
'description': 'description':
"Assign metadata to documents consumed from this rule " _("Assign metadata to documents consumed from this rule "
"automatically. If you do not assign tags, types or " "automatically. If you do not assign tags, types or "
"correspondents here, paperless will still process all " "correspondents here, paperless will still process all "
"matching rules that you have defined.", "matching rules that you have defined."),
"fields": ( "fields": (
'assign_title_from', 'assign_title_from',
'assign_tag', 'assign_tag',

View File

@ -2,6 +2,8 @@ from django.db import models
import documents.models as document_models import documents.models as document_models
from django.utils.translation import gettext_lazy as _
class MailAccount(models.Model): class MailAccount(models.Model):
@ -10,29 +12,39 @@ class MailAccount(models.Model):
IMAP_SECURITY_STARTTLS = 3 IMAP_SECURITY_STARTTLS = 3
IMAP_SECURITY_OPTIONS = ( IMAP_SECURITY_OPTIONS = (
(IMAP_SECURITY_NONE, "No encryption"), (IMAP_SECURITY_NONE, _("No encryption")),
(IMAP_SECURITY_SSL, "Use SSL"), (IMAP_SECURITY_SSL, _("Use SSL")),
(IMAP_SECURITY_STARTTLS, "Use STARTTLS"), (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 = models.IntegerField(
_("imap port"),
blank=True, blank=True,
null=True, null=True,
help_text="This is usually 143 for unencrypted and STARTTLS " help_text=_("This is usually 143 for unencrypted and STARTTLS "
"connections, and 993 for SSL connections.") "connections, and 993 for SSL connections."))
imap_security = models.PositiveIntegerField( imap_security = models.PositiveIntegerField(
_("imap security"),
choices=IMAP_SECURITY_OPTIONS, choices=IMAP_SECURITY_OPTIONS,
default=IMAP_SECURITY_SSL 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): def __str__(self):
return self.name return self.name
@ -46,18 +58,18 @@ class MailRule(models.Model):
ACTION_FLAG = 4 ACTION_FLAG = 4
ACTIONS = ( ACTIONS = (
(ACTION_MARK_READ, "Mark as read, don't process read mails"), (ACTION_MARK_READ, _("Mark as read, don't process read mails")),
(ACTION_FLAG, "Flag the mail, don't process flagged mails"), (ACTION_FLAG, _("Flag the mail, don't process flagged mails")),
(ACTION_MOVE, "Move to specified folder"), (ACTION_MOVE, _("Move to specified folder")),
(ACTION_DELETE, "Delete"), (ACTION_DELETE, _("Delete")),
) )
TITLE_FROM_SUBJECT = 1 TITLE_FROM_SUBJECT = 1
TITLE_FROM_FILENAME = 2 TITLE_FROM_FILENAME = 2
TITLE_SELECTOR = ( TITLE_SELECTOR = (
(TITLE_FROM_SUBJECT, "Use subject as title"), (TITLE_FROM_SUBJECT, _("Use subject as title")),
(TITLE_FROM_FILENAME, "Use attachment filename as title") (TITLE_FROM_FILENAME, _("Use attachment filename as title"))
) )
CORRESPONDENT_FROM_NOTHING = 1 CORRESPONDENT_FROM_NOTHING = 1
@ -67,47 +79,65 @@ class MailRule(models.Model):
CORRESPONDENT_SELECTOR = ( CORRESPONDENT_SELECTOR = (
(CORRESPONDENT_FROM_NOTHING, (CORRESPONDENT_FROM_NOTHING,
"Do not assign a correspondent"), _("Do not assign a correspondent")),
(CORRESPONDENT_FROM_EMAIL, (CORRESPONDENT_FROM_EMAIL,
"Use mail address"), "Use mail address"),
(CORRESPONDENT_FROM_NAME, (CORRESPONDENT_FROM_NAME,
"Use name (or mail address if not available)"), _("Use name (or mail address if not available)")),
(CORRESPONDENT_FROM_CUSTOM, (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( account = models.ForeignKey(
MailAccount, MailAccount,
related_name="rules", 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_from = models.CharField(
filter_subject = models.CharField(max_length=256, null=True, blank=True) _("filter from"),
filter_body = models.CharField(max_length=256, null=True, blank=True) 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 = models.PositiveIntegerField(
_("maximum age"),
default=30, default=30,
help_text="Specified in days.") help_text=_("Specified in days."))
action = models.PositiveIntegerField( action = models.PositiveIntegerField(
_("action"),
choices=ACTIONS, choices=ACTIONS,
default=ACTION_MARK_READ, default=ACTION_MARK_READ,
) )
action_parameter = models.CharField( action_parameter = models.CharField(
_("action parameter"),
max_length=256, blank=True, null=True, max_length=256, blank=True, null=True,
help_text="Additional parameter for the action selected above, i.e., " help_text=_("Additional parameter for the action selected above, "
"the target folder of the move to folder action." "i.e., "
"the target folder of the move to folder action.")
) )
assign_title_from = models.PositiveIntegerField( assign_title_from = models.PositiveIntegerField(
_("assign title from"),
choices=TITLE_SELECTOR, choices=TITLE_SELECTOR,
default=TITLE_FROM_SUBJECT default=TITLE_FROM_SUBJECT
) )
@ -116,17 +146,20 @@ class MailRule(models.Model):
document_models.Tag, document_models.Tag,
null=True, null=True,
blank=True, blank=True,
on_delete=models.SET_NULL on_delete=models.SET_NULL,
verbose_name=_("assign this tag"),
) )
assign_document_type = models.ForeignKey( assign_document_type = models.ForeignKey(
document_models.DocumentType, document_models.DocumentType,
null=True, null=True,
blank=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 = models.PositiveIntegerField(
_("assign correspondent from"),
choices=CORRESPONDENT_SELECTOR, choices=CORRESPONDENT_SELECTOR,
default=CORRESPONDENT_FROM_NOTHING default=CORRESPONDENT_FROM_NOTHING
) )
@ -135,7 +168,8 @@ class MailRule(models.Model):
document_models.Correspondent, document_models.Correspondent,
null=True, null=True,
blank=True, blank=True,
on_delete=models.SET_NULL on_delete=models.SET_NULL,
verbose_name=_("assign this correspondent")
) )
def __str__(self): def __str__(self):