From 1c9cc33902d8242ec25b4416a1662ee6c9902583 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 28 Jul 2019 12:50:10 +0200 Subject: [PATCH] Try to localise timestamps I'm not sure, if that is the right way, but Qt doesn't really have a way to format custom localised dates, so I tried to find the closest approximations to what we currently have. Relates to #69 --- resources/langs/nheko_de.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_el.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_en.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_fr.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_nl.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_pl.ts | 101 +++++++++++++++++++++++++------- resources/langs/nheko_ru.ts | 103 ++++++++++++++++++++++++++------- resources/langs/nheko_zh_CN.ts | 101 +++++++++++++++++++++++++------- src/Utils.cpp | 20 +++---- src/dialogs/MemberList.cpp | 4 +- src/dialogs/ReadReceipts.cpp | 12 ++-- src/timeline/TimelineItem.cpp | 2 +- src/ui/InfoMessage.cpp | 13 +++-- 13 files changed, 668 insertions(+), 193 deletions(-) diff --git a/resources/langs/nheko_de.ts b/resources/langs/nheko_de.ts index f592a4d8..8c92c084 100644 --- a/resources/langs/nheko_de.ts +++ b/resources/langs/nheko_de.ts @@ -4,7 +4,7 @@ AudioItem - + Save File In Datei speichern @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Hochladen der Bilddatei fehlgeschlagen. Bitte versuche es erneut. @@ -32,7 +32,7 @@ Hochladen der Videodatei fehlgeschlagen. Bitte versuche es erneut. - + Failed to restore OLM account. Please login again. Wiederherstellung des OLM Accounts fehlgeschlagen. Bitte logge dich erneut ein. @@ -42,7 +42,7 @@ Nachrichten konnten nicht aus dem Cache geladen werden. Bitte melde dich erneut an. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Erstellung des Schlüsselmaterials fehlgeschlagen. Antwort des Servers: %1 %2. Bitte versuche es später erneut. @@ -118,7 +118,7 @@ FileItem - + Save File Datei speichern @@ -126,7 +126,7 @@ ImageItem - + Save image Bild speichern @@ -205,8 +205,8 @@ Teilnehmerliste - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Raum verlassen - + Accept Akzeptieren @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Schreibe eine Nachricht... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Benutzer einladen @@ -460,7 +465,7 @@ TypingDisplay - + is typing tippt @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Ins Benachrichtigungsfeld minimieren @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Erscheinungsbild @@ -566,7 +576,7 @@ ALLGEMEINES - + Open Sessions File @@ -635,6 +645,14 @@ ANMELDEN + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Medien-Größe: %2 dialogs::ReadReceipts - + Read receipts Lesebestätigungen @@ -793,6 +811,19 @@ Medien-Größe: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1003,4 +1034,32 @@ Medien-Größe: %2 Flaggen + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_el.ts b/resources/langs/nheko_el.ts index 5a6be4cb..74b14266 100644 --- a/resources/langs/nheko_el.ts +++ b/resources/langs/nheko_el.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Αποθήκευση @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Αποθήκευση @@ -126,7 +126,7 @@ ImageItem - + Save image Αποθήκευση Εικόνας @@ -205,8 +205,8 @@ Μέλη - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Βγές - + Accept Αποδοχή @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Γράψε ένα μήνυμα... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Προσκάλεσε χρήστες @@ -460,7 +465,7 @@ TypingDisplay - + is typing πληκτρολογεί @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Ελαχιστοποίηση @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Φόντο @@ -566,7 +576,7 @@ ΓΕΝΙΚΑ - + Open Sessions File @@ -635,6 +645,14 @@ ΕΙΣΟΔΟΣ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -776,7 +794,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts @@ -791,6 +809,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1001,4 +1032,32 @@ Media size: %2 Σημαίες + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_en.ts b/resources/langs/nheko_en.ts index d8259dc5..5c4bad0e 100644 --- a/resources/langs/nheko_en.ts +++ b/resources/langs/nheko_en.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Save File @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Failed to upload image. Please try again. @@ -32,7 +32,7 @@ Failed to upload video. Please try again. - + Failed to restore OLM account. Please login again. Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ Failed to restore save data. Please login again. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Save File @@ -126,7 +126,7 @@ ImageItem - + Save image Save image @@ -205,8 +205,8 @@ Room members - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Leave room - + Accept Accept @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users @@ -460,7 +465,7 @@ TypingDisplay - + is typing @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme @@ -566,7 +576,7 @@ - + Open Sessions File @@ -635,6 +645,14 @@ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -776,7 +794,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts @@ -791,6 +809,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1001,4 +1032,32 @@ Media size: %2 Flags + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_fr.ts b/resources/langs/nheko_fr.ts index beab8752..f8425e26 100644 --- a/resources/langs/nheko_fr.ts +++ b/resources/langs/nheko_fr.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Enregistrer le fichier @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Enregistrer le fichier @@ -126,7 +126,7 @@ ImageItem - + Save image Enregistrer l'image @@ -205,8 +205,8 @@ Membres du salon - - ESC + + OK @@ -278,7 +278,7 @@ RoomInfo - + no version stored @@ -286,12 +286,12 @@ RoomInfoListItem - + Leave room Quitter le salon - + Accept Accepter @@ -332,7 +332,7 @@ StatusIndicator - + Encrypted @@ -355,13 +355,13 @@ TextInputWidget - + Send a file - + Write a message... Écrivez un message... @@ -425,7 +425,12 @@ - + + Mentions + + + + Invite users Inviter des utilisateurs @@ -461,7 +466,7 @@ TypingDisplay - + is typing est en train d'écrire @@ -482,7 +487,7 @@ UserSettingsPage - + Minimize to tray Réduire à la barre des tâches @@ -522,12 +527,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Thème @@ -567,7 +577,7 @@ GÉNÉRAL - + Open Sessions File @@ -636,6 +646,14 @@ CONNEXION + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -779,7 +797,7 @@ Taille du média : %2 dialogs::ReadReceipts - + Read receipts Accusés de lecture @@ -794,6 +812,19 @@ Taille du média : %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1004,4 +1035,32 @@ Taille du média : %2 Drapeaux + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_nl.ts b/resources/langs/nheko_nl.ts index 4c81ec76..51ec18fe 100644 --- a/resources/langs/nheko_nl.ts +++ b/resources/langs/nheko_nl.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Bestand opslaan @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. @@ -32,7 +32,7 @@ - + Failed to restore OLM account. Please login again. @@ -42,7 +42,7 @@ - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Bestand opslaan @@ -126,7 +126,7 @@ ImageItem - + Save image Afbeelding opslaan @@ -205,8 +205,8 @@ Kamerleden - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Kamer verlaten - + Accept Accepteren @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted @@ -354,13 +354,13 @@ TextInputWidget - + Send a file - + Write a message... Typ een bericht... @@ -424,7 +424,12 @@ - + + Mentions + + + + Invite users Gebruikers uitnodigen @@ -460,7 +465,7 @@ TypingDisplay - + is typing is aan het typen @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Minimaliseren naar systeemvak @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Thema @@ -566,7 +576,7 @@ ALGEMEEN - + Open Sessions File @@ -635,6 +645,14 @@ INLOGGEN + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Mediagrootte: %2 dialogs::ReadReceipts - + Read receipts Leesbevestigingen @@ -793,6 +811,19 @@ Mediagrootte: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1003,4 +1034,32 @@ Mediagrootte: %2 Vlaggen + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_pl.ts b/resources/langs/nheko_pl.ts index edea85b9..ca021554 100644 --- a/resources/langs/nheko_pl.ts +++ b/resources/langs/nheko_pl.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Zapisz plik @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Nie udało się wysłać obrazu. Spróbuj ponownie. @@ -32,7 +32,7 @@ Nie udało się wysłać filmu. Spróbuj ponownie. - + Failed to restore OLM account. Please login again. Nie udało się przywrócić konta OLM. Spróbuj zalogować się ponownie. @@ -42,7 +42,7 @@ Nie udało się przywrócić zapisanych danych. Spróbuj zalogować się ponownie. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File Zapisz plik @@ -126,7 +126,7 @@ ImageItem - + Save image Zapisz obraz @@ -205,8 +205,8 @@ Członkowie pokoju - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Opuść pokój - + Accept Akceptuj @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted Szyfrowana @@ -354,13 +354,13 @@ TextInputWidget - + Send a file Wyślij plik - + Write a message... Napisz wiadomość… @@ -424,7 +424,12 @@ Ustawienia pokoju - + + Mentions + + + + Invite users Zaproś użytkowników @@ -460,7 +465,7 @@ TypingDisplay - + is typing pisze @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Zminimalizuj do paska zadań @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme Motyw @@ -566,7 +576,7 @@ OGÓLNE - + Open Sessions File @@ -635,6 +645,14 @@ ZALOGUJ SIĘ + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Rozmiar multimediów: %2 dialogs::ReadReceipts - + Read receipts Potwierdzenia przeczytania @@ -793,6 +811,19 @@ Rozmiar multimediów: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1006,4 +1037,32 @@ Rozmiar multimediów: %2 Flagi + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_ru.ts b/resources/langs/nheko_ru.ts index 4c157884..39cf7b72 100644 --- a/resources/langs/nheko_ru.ts +++ b/resources/langs/nheko_ru.ts @@ -4,7 +4,7 @@ AudioItem - + Save File Сохранить файл @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. Не удалось загрузить изображение. Пожалуйста, попробуйте еще раз. @@ -32,7 +32,7 @@ Не удалось загрузить видео. Пожалуйста, попробуйте еще раз. - + Failed to restore OLM account. Please login again. Не удалось восстановить учетную запись OLM. Пожалуйста, войдите снова. @@ -42,7 +42,7 @@ Не удалось восстановить сохраненные данные. Пожалуйста, войдите снова. - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. Не удалось настроить ключи шифрования. Ответ сервера:%1 %2. Пожалуйста, попробуйте позже. @@ -118,7 +118,7 @@ FileItem - + Save File Сохранить файл @@ -126,7 +126,7 @@ ImageItem - + Save image Сохранить изображение @@ -205,9 +205,9 @@ Участники комнаты - - ESC - + + OK + @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room Покинуть комнату - + Accept Принять @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted Зашифровано @@ -354,13 +354,13 @@ TextInputWidget - + Send a file Отправить файл - + Write a message... Написать сообщение... @@ -424,7 +424,12 @@ Настройки комнаты - + + Mentions + + + + Invite users Пригласить пользователей @@ -460,7 +465,7 @@ TypingDisplay - + is typing печатает @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray Сворачивать в системную панель @@ -521,12 +526,17 @@ Размер шрифта - + Font Family - + + Emoji Font Famly + + + + Theme Тема @@ -566,7 +576,7 @@ ГЛАВНОЕ - + Open Sessions File Открыть файл сеансов @@ -636,6 +646,14 @@ ВХОД + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -779,7 +797,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts Подтверждать прочтение @@ -794,6 +812,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1005,4 +1036,32 @@ Media size: %2 + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/resources/langs/nheko_zh_CN.ts b/resources/langs/nheko_zh_CN.ts index ca7c6e22..08463cd7 100644 --- a/resources/langs/nheko_zh_CN.ts +++ b/resources/langs/nheko_zh_CN.ts @@ -4,7 +4,7 @@ AudioItem - + Save File 保存文件 @@ -12,7 +12,7 @@ ChatPage - + Failed to upload image. Please try again. 上传图像失败。请重试。 @@ -32,7 +32,7 @@ 上传视频失败。请重试。 - + Failed to restore OLM account. Please login again. 恢复 OLM 账户失败。请重新登录。 @@ -42,7 +42,7 @@ 恢复保存的数据失败。请重新登录。 - + Failed to setup encryption keys. Server response: %1 %2. Please try again later. @@ -118,7 +118,7 @@ FileItem - + Save File 保存文件 @@ -126,7 +126,7 @@ ImageItem - + Save image 保存图像 @@ -205,8 +205,8 @@ 聊天室成员 - - ESC + + OK @@ -277,7 +277,7 @@ RoomInfo - + no version stored @@ -285,12 +285,12 @@ RoomInfoListItem - + Leave room 离开聊天室 - + Accept 接受 @@ -331,7 +331,7 @@ StatusIndicator - + Encrypted 加密的 @@ -354,13 +354,13 @@ TextInputWidget - + Send a file 发送一个文件 - + Write a message... 写一条消息... @@ -424,7 +424,12 @@ 聊天室选项 - + + Mentions + + + + Invite users 邀请用户 @@ -460,7 +465,7 @@ TypingDisplay - + is typing 正在打字 @@ -481,7 +486,7 @@ UserSettingsPage - + Minimize to tray 最小化至托盘 @@ -521,12 +526,17 @@ - + Font Family - + + Emoji Font Famly + + + + Theme 主题 @@ -566,7 +576,7 @@ 通用 - + Open Sessions File 打开会话文件 @@ -635,6 +645,14 @@ 登录 + + descriptiveTime + + + Yesterday + + + dialogs::CreateRoom @@ -778,7 +796,7 @@ Media size: %2 dialogs::ReadReceipts - + Read receipts 阅读回执 @@ -793,6 +811,19 @@ Media size: %2 + + dialogs::ReceiptItem + + + Today %1 + + + + + Yesterday %1 + + + dialogs::RoomSettings @@ -1012,4 +1043,32 @@ Media size: %2 Flags + + utils + + + You + + + + + sent a file. + + + + + sent an image. + + + + + sent an audio file. + + + + + sent a video + + + diff --git a/src/Utils.cpp b/src/Utils.cpp index d6b092b1..a3c15c96 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -99,13 +99,13 @@ utils::descriptiveTime(const QDateTime &then) const auto days = then.daysTo(now); if (days == 0) - return then.toString("HH:mm"); + return then.time().toString(Qt::DefaultLocaleShortDate); else if (days < 2) - return QString("Yesterday"); - else if (days < 365) - return then.toString("dd/MM"); + return QString(QCoreApplication::translate("descriptiveTime", "Yesterday")); + else if (days < 7) + return then.toString("dddd"); - return then.toString("dd/MM/yy"); + return then.date().toString(Qt::DefaultLocaleShortDate); } DescInfo @@ -147,7 +147,7 @@ utils::getMessageDescription(const TimelineEvent &event, DescInfo info; if (sender == localUser) - info.username = "You"; + info.username = QCoreApplication::translate("utils", "You"); else info.username = username; @@ -366,16 +366,16 @@ utils::getQuoteBody(const RelatedInfo &related) return markdownToHtml(related.quoted_body); } case MsgType::File: { - return QString("sent a file."); + return QString(QCoreApplication::translate("utils", "sent a file.")); } case MsgType::Image: { - return QString("sent an image."); + return QString(QCoreApplication::translate("utils", "sent an image.")); } case MsgType::Audio: { - return QString("sent an audio file."); + return QString(QCoreApplication::translate("utils", "sent an audio file.")); } case MsgType::Video: { - return QString("sent a video"); + return QString(QCoreApplication::translate("utils", "sent a video")); } default: { return related.quoted_body; diff --git a/src/dialogs/MemberList.cpp b/src/dialogs/MemberList.cpp index f4167143..3b957c15 100644 --- a/src/dialogs/MemberList.cpp +++ b/src/dialogs/MemberList.cpp @@ -97,7 +97,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) topLabel_->setAlignment(Qt::AlignCenter); topLabel_->setFont(font); - auto okBtn = new QPushButton("OK", this); + auto okBtn = new QPushButton(tr("OK"), this); auto buttonLayout = new QHBoxLayout(); buttonLayout->setSpacing(15); @@ -126,7 +126,7 @@ MemberList::MemberList(const QString &room_id, QWidget *parent) qCritical() << e.what(); } - auto closeShortcut = new QShortcut(QKeySequence(tr("ESC")), this); + auto closeShortcut = new QShortcut(QKeySequence("ESC"), this); connect(closeShortcut, &QShortcut::activated, this, &MemberList::close); connect(okBtn, &QPushButton::clicked, this, &MemberList::close); } diff --git a/src/dialogs/ReadReceipts.cpp b/src/dialogs/ReadReceipts.cpp index dc4145db..03ce3068 100644 --- a/src/dialogs/ReadReceipts.cpp +++ b/src/dialogs/ReadReceipts.cpp @@ -78,13 +78,15 @@ ReceiptItem::dateFormat(const QDateTime &then) const auto days = then.daysTo(now); if (days == 0) - return QString("Today %1").arg(then.toString("HH:mm")); + return tr("Today %1").arg(then.time().toString(Qt::DefaultLocaleShortDate)); else if (days < 2) - return QString("Yesterday %1").arg(then.toString("HH:mm")); - else if (days < 365) - return then.toString("dd/MM HH:mm"); + return tr("Yesterday %1").arg(then.time().toString(Qt::DefaultLocaleShortDate)); + else if (days < 7) + return QString("%1 %2") + .arg(then.toString("dddd")) + .arg(then.time().toString(Qt::DefaultLocaleShortDate)); - return then.toString("dd/MM/yy"); + return then.toString(Qt::DefaultLocaleShortDate); } ReadReceipts::ReadReceipts(QWidget *parent) diff --git a/src/timeline/TimelineItem.cpp b/src/timeline/TimelineItem.cpp index e52dce7b..c0d7f97f 100644 --- a/src/timeline/TimelineItem.cpp +++ b/src/timeline/TimelineItem.cpp @@ -951,4 +951,4 @@ TimelineItem::openRawMessageViewer() const "failed to serialize event ({}, {})", room_id, event_id); } }); -} \ No newline at end of file +} diff --git a/src/ui/InfoMessage.cpp b/src/ui/InfoMessage.cpp index fa575d76..27bc0a5f 100644 --- a/src/ui/InfoMessage.cpp +++ b/src/ui/InfoMessage.cpp @@ -2,6 +2,7 @@ #include "Config.h" #include +#include #include #include #include @@ -61,14 +62,14 @@ DateSeparator::DateSeparator(QDateTime datetime, QWidget *parent) { auto now = QDateTime::currentDateTime(); - QString fmt; + QString fmt = QLocale::system().dateFormat(QLocale::LongFormat); - if (now.date().year() != datetime.date().year()) - fmt = QString("ddd d MMMM yy"); - else - fmt = QString("ddd d MMMM"); + if (now.date().year() == datetime.date().year()) { + QRegularExpression rx("[^a-zA-Z]*y+[^a-zA-Z]*"); + fmt = fmt.remove(rx); + } - msg_ = datetime.toString(fmt); + msg_ = datetime.date().toString(fmt); QFontMetrics fm{font()}; #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)