Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Localize last edited time on information pages #425

Merged
merged 4 commits into from
Jan 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions myhpi/core/templates/core/information_page.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{% extends "base.html" %}
{% load core_extras %}
{% load i18n %}
{% load tz %}

{% block content %}
{% with page.body|markdown as parsed_md %}
Expand All @@ -17,9 +18,14 @@ <h1 class="page-title">
<div class="side-panel-container">
<aside class="side-panel border-accent">
<h1 class="toc-title">{% translate "Last edited" %}</h1>
{{ page.last_published_at|date:"d.m.Y, H:i" }}
{% get_current_timezone as TIMEZONE %}
<time id="last-published" datetime="{{ page.last_published_at|date:"c" }}" title="{{ TIMEZONE }}">
{% blocktranslate with date=page.last_published_at|date:"SHORT_DATE_FORMAT" time=page.last_published_at|time:"TIME_FORMAT" trimmed %}
{{ date }} at {{ time }}
{% endblocktranslate %}
</time>
{% if page.author_visible %}
<i>{% translate "by" %}</i>
{% translate "by" %}
{{ page.last_edited_by }}
{% endif %}
</aside>
Expand All @@ -43,4 +49,4 @@ <h1 class="toc-title">{% translate "Attachments" %}</h1>
</div>
</div>
{% endwith %}
{% endblock %}
{% endblock %}
48 changes: 26 additions & 22 deletions myhpi/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-11-09 16:35+0100\n"
"POT-Creation-Date: 2023-12-12 19:24+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand All @@ -18,74 +18,73 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"

#: core/markdown/extensions.py:55
#: core/markdown/extensions.py:53
msgid "Begin of meeting"
msgstr "Beginn des Meetings"

#: core/markdown/extensions.py:58
#: core/markdown/extensions.py:56
msgid "End of meeting"
msgstr "Ende des Meetings"

#: core/markdown/extensions.py:72
#: core/markdown/extensions.py:70
#, python-brace-format
msgid "*Meeting break: {time_start_break} – {time_end_break}*"
msgstr "*Sitzungspause: {time_start_break} – {time_end_break}*"

#: core/markdown/extensions.py:89
#: core/markdown/extensions.py:87
msgid "quorate"
msgstr "beschlussfähig"

#: core/markdown/extensions.py:89
#: core/markdown/extensions.py:87
msgid "not quorate"
msgstr "nicht beschlussfähig"

#: core/markdown/extensions.py:92
#: core/markdown/extensions.py:90
#, python-brace-format
msgid "*{num_participants}/{max_num_participants} present → {quorate}* "
msgstr "*{num_participants}/{max_num_participants} anwesend → {quorate}* "

#: core/markdown/extensions.py:116
#: core/markdown/extensions.py:114
#, python-brace-format
msgid "*{time}: {name} {event} the meeting* "
msgstr "*{time}: {name} {event} das Meeting* "

#: core/markdown/extensions.py:121
#: core/markdown/extensions.py:119
#, python-brace-format
msgid "*{time}: {name} {event} the meeting via {mean_of_participation}* "
msgstr "*{time}: {name} {event} das Meeting via {mean_of_participation}* "

#: core/markdown/extensions.py:131
#: core/markdown/extensions.py:129
msgid "enters"
msgstr "betritt"

#: core/markdown/extensions.py:134
#: core/markdown/extensions.py:132
msgid "leaves"
msgstr "verlässt"

#: core/markdown/extensions.py:155
#: core/markdown/extensions.py:153
msgid "[missing link]"
msgstr "[link fehlt]"

#: core/markdown/extensions.py:174
#, fuzzy
#| msgid "[missing link]"
msgid "[missing image]"
msgstr "[link fehlt]"

#: core/templates/core/information_page.html:19
#: core/templates/core/information_page.html:20
msgid "Last edited"
msgstr "Zuletzt bearbeitet"

#: core/templates/core/information_page.html:22
#: core/templates/core/information_page.html:23
#, python-format
msgid "%(date)s at %(time)s"
msgstr "%(date)s um %(time)s Uhr"

#: core/templates/core/information_page.html:28
msgid "by"
msgstr "von"

#: core/templates/core/information_page.html:27
#: core/templates/core/information_page.html:33
#: core/templates/core/minutes.html:47 polls/templates/polls/poll.html:29
msgid "Table of contents"
msgstr "Inhaltsverzeichnis"

#: core/templates/core/information_page.html:32
#: core/templates/core/information_page.html:38
#: core/templates/core/minutes.html:50
msgid "Attachments"
msgstr "Anhänge"
Expand Down Expand Up @@ -510,6 +509,11 @@ msgstr "{email} hat erfolgreich {list} verlassen."
msgid "The subscription of {email} onto {list} was rolled back."
msgstr "Die Anmeldung von {email} auf {list} wurde rückgänig gemacht."

#, fuzzy
#~| msgid "[missing link]"
#~ msgid "[missing image]"
#~ msgstr "[link fehlt]"

#~ msgid "Sorry, this page could not be found."
#~ msgstr ""
#~ " Die angeforderte Seite existiert nicht. Bitte überprüfe die URL oder "
Expand Down
2 changes: 1 addition & 1 deletion myhpi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@

LANGUAGE_CODE = "de"

TIME_ZONE = "UTC"
TIME_ZONE = "Europe/Berlin"

USE_I18N = True
WAGTAIL_I18N_ENABLED = True
Expand Down
27 changes: 26 additions & 1 deletion myhpi/static/js/myHPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,29 @@ const toggleElementVisibilityOnScroll = (minScrollPosition = 0) => {
previousScrollPosition = currentScrollPosition
}

const localizeLastPublished = () => {
dropforge marked this conversation as resolved.
Show resolved Hide resolved
const lastPublished = document.getElementById("last-published")
const timezone_server = lastPublished.getAttribute("title")
const timezone_user = Intl.DateTimeFormat().resolvedOptions().timeZone

if(timezone_server !== timezone_user) {
lastPublishedLocalized = new Date(lastPublished.getAttribute("datetime")).toLocaleString(undefined, {
year: "numeric", month: "numeric", day: "numeric",
hour: "numeric", minute: "2-digit",
timeZoneName: "short"
})

// replace <time> width <abbr> tag
let abbr = document.createElement("abbr");
abbr.setAttribute("title", lastPublishedLocalized)
lastPublished.removeAttribute("title")

let parent = lastPublished.parentNode;
parent.replaceChild(abbr, lastPublished);
abbr.appendChild(lastPublished);
}
}

const enableTooltips = () => {
const tooltipTriggerList = document.querySelectorAll(
'[data-bs-toggle="tooltip"]'
Expand All @@ -73,6 +96,8 @@ window.onload = () => {

initializeSearch()

localizeLastPublished()

enableTooltips()

}
Expand All @@ -83,4 +108,4 @@ window.onscroll = () => {
window.onresize = () => {
adaptNavbarToWindowSize()
updateNavbarPosition()
}
}
Loading