Skip to content

Commit

Permalink
Enable internationalization for URL status messages
Browse files Browse the repository at this point in the history
  • Loading branch information
timobrembeck authored and claudep committed Mar 19, 2023
1 parent 1367451 commit 5899135
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Unreleased

* Enable internationalization for URL status messages (Timo Ludwig, #125)
* Enable re-checking after rate limit was hit (Timo Ludwig, #153)
* Ignore raw `post_save` signal (Timo Ludwig, #106)
* Retry with fallback user agent on forbidden response (Timo Ludwig, #159)
Expand Down
89 changes: 80 additions & 9 deletions linkcheck/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-02-22 22:35+0100\n"
"POT-Creation-Date: 2023-02-28 23:01+0100\n"
"Language: German\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -53,38 +53,106 @@ msgstr[0] ""
msgstr[1] ""
"Das Löschen von {} hat dazu geführt, dass {} Links nicht mehr funktionieren."

#: models.py:111
#: models.py:118
msgid "Working empty anchor"
msgstr "Funktionierender leerer Anker"

#: models.py:113
#: models.py:120
msgid "Anchor could not be checked"
msgstr "Anker konnte nicht geprüft werden"

#: models.py:115
#: models.py:122
msgid "Broken anchor"
msgstr "Ungültiger Anker"

#: models.py:116
#: models.py:123
msgid "Working anchor"
msgstr "Funktionierender Anker"

#: models.py:123
#: models.py:130
msgid "Insecure link"
msgstr "Unsicherer Link"

#: models.py:125
#: models.py:132
msgid "SSL certificate could not be checked"
msgstr "SSL-Zertifikat konnte nicht überprüft werden"

#: models.py:127
#: models.py:134
msgid "Broken SSL certificate"
msgstr "Fehlerhaftes SSL-Zertifikat"

#: models.py:128
#: models.py:135
msgid "Valid SSL certificate"
msgstr "Valides SSL-Zertifikat"

#: models.py:140
msgid "URL Not Yet Checked"
msgstr "URL noch nicht geprüft"

#: models.py:142
msgid "Empty link"
msgstr "Leerer Link"

#: models.py:144
msgid "Invalid URL"
msgstr "Ungültige URL"

#: models.py:146
msgid "Email link"
msgstr "Email-Link"

#: models.py:146 models.py:148 models.py:150
msgid "not automatically checked"
msgstr "nicht automatisch geprüft"

#: models.py:148
msgid "Phone number link"
msgstr "Telefonnummern-Link"

#: models.py:150
msgid "Anchor link"
msgstr "Anker-Link"

#: models.py:152
msgid "Working file link"
msgstr "Funktionierender Datei-Link"

#: models.py:152
msgid "Missing file"
msgstr "Fehlende Datei"

#: models.py:156
msgid "Working external link"
msgstr "Funktionierender externer Link"

#: models.py:156
msgid "Working internal link"
msgstr "Funktionierender interner Link"

#: models.py:160
msgid "Working permanent redirect"
msgstr "Funktionierende dauerhafte Weiterleitung"

#: models.py:160
msgid "Working temporary redirect"
msgstr "Funktionierende temporäre Weiterleitung"

#: models.py:162
msgid "Broken permanent redirect"
msgstr "Fehlerhafte dauerhafte Weiterleitung"

#: models.py:162
msgid "Broken temporary redirect"
msgstr "Fehlerhafte temporäre Weiterleitung"

#: models.py:163
msgid "Broken external link"
msgstr "Fehlerhafter externer Link"

#: models.py:163
msgid "Broken internal link"
msgstr "Fehlerhafter interner Link"

#: templates/linkcheck/base_linkcheck.html:5
#: templates/linkcheck/base_linkcheck.html:11
#: templates/linkcheck/base_linkcheck.html:17
Expand Down Expand Up @@ -199,3 +267,6 @@ msgstr "Nicht ignorieren"
#: templates/linkcheck/report.html:173
msgid "Redirects to"
msgstr "Leitet weiter zu"

#~ msgid "Link to section on same page"
#~ msgstr "Link zu Abschnitt auf derselben Seite"
33 changes: 29 additions & 4 deletions linkcheck/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ class Url(models.Model):
error_message = models.CharField(max_length=1024, default='', blank=True)
redirect_to = models.TextField(blank=True)

@property
def redirect_ok(self):
return self.redirect_status_code < 300 if self.redirect_status_code else None

@property
def type(self):
if self.external:
Expand Down Expand Up @@ -132,10 +136,31 @@ def ssl_message(self):

@property
def get_message(self):
if self.last_checked:
return self.message
else:
return "URL Not Yet Checked"
if not self.last_checked:
return _('URL Not Yet Checked')
elif self.type == 'empty':
return _('Empty link')
elif self.type == 'invalid':
return _('Invalid URL')
elif self.type == 'mailto':
return '{} ({})'.format(_("Email link"), _("not automatically checked"))
elif self.type == 'phone':
return '{} ({})'.format(_("Phone number link"), _("not automatically checked"))
elif self.type == 'anchor':
return '{} ({})'.format(_("Anchor link"), _("not automatically checked"))
elif self.type == 'file':
return _('Working file link') if self.status else _('Missing file')
elif not self.status_code:
return self.error_message
elif self.status_code < 300:
return _('Working external link') if self.external else _('Working internal link')
elif self.status_code < 400:
permanent = self.status_code in [HTTPStatus.MOVED_PERMANENTLY, HTTPStatus.PERMANENT_REDIRECT]
if self.redirect_ok:
return _('Working permanent redirect') if permanent else _('Working temporary redirect')
else:
return _('Broken permanent redirect') if permanent else _('Broken temporary redirect')
return _('Broken external link') if self.external else _('Broken internal link')

@property
def colour(self):
Expand Down
Loading

0 comments on commit 5899135

Please sign in to comment.