data/MessageLanguageText.h
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <QDateTime> | ||
| 4 | #include <QLocale> | ||
| 5 | #include <QString> | ||
| 6 | #include <QTimeZone> | ||
| 7 | |||
| 8 | // Sprint 108 S108.2.7 (D-10, §4.17): the text MailJD writes into a message — | ||
| 9 | // quote attribution, forward header, image markers, the suggest-times block | ||
| 10 | // and the invitation card — in the **message** language with that | ||
| 11 | // language's date format, never in the UI language. German and English | ||
| 12 | // have their own table; every other language falls back to English. | ||
| 13 | class MessageLanguageText { | ||
| 14 | public: | ||
| 15 | enum class Label { When, Where, Join, Organizer, Attendees, ForwardedMessage, From, Date, Subject, To }; | ||
| 16 | |||
| 17 | // "de", "de_DE", "de-AT", "en_US" … → the table's language. | ||
| 18 | explicit MessageLanguageText(const QString &language = QStringLiteral("en")); | ||
| 19 | 4 | QString language() const { return m_language; } | |
| 20 | QLocale locale() const { return m_locale; } | ||
| 21 | |||
| 22 | // The message language for a draft: the spell-check language when one is | ||
| 23 | // set, else the UI language (D-10). | ||
| 24 | static QString messageLanguage(const QString &spellLanguage, const QString &uiLanguage); | ||
| 25 | |||
| 26 | QString label(Label label) const; | ||
| 27 | // "On Tue, 14 Oct 2026 at 09:12, Anna Berg wrote:" / | ||
| 28 | // "Am 14.10.2026 um 09:12 schrieb Anna Berg:" | ||
| 29 | QString attribution(const QDateTime &when, const QString &author) const; | ||
| 30 | // The block above a forwarded message (one line per field, no trailing | ||
| 31 | // newline); the To line only when `to` is not empty. | ||
| 32 | QString forwardHeader(const QString &from, const QDateTime &when, const QString &subject, | ||
| 33 | const QString &to = {}) const; | ||
| 34 | // "[image: %1]" / "[Bild: %1]" | ||
| 35 | QString imageMarker() const; | ||
| 36 | // "Would one of these suit you?" / "Passt einer dieser Termine?" | ||
| 37 | QString suggestTimesIntro() const; | ||
| 38 | // "Tue 21 Oct, 10:00–11:00" / "Di. 21. Okt., 10:00–11:00"; an end on | ||
| 39 | // another day repeats the date. | ||
| 40 | QString timeSlot(const QDateTime &start, const QDateTime &end) const; | ||
| 41 | // "Times in Europe/Berlin" / "Zeiten in Europe/Berlin" | ||
| 42 | QString timeZoneNote(const QTimeZone &zone) const; | ||
| 43 | QString dateTime(const QDateTime &when) const; | ||
| 44 | |||
| 45 | private: | ||
| 46 | QString m_language; | ||
| 47 | QLocale m_locale; | ||
| 48 | 340 | bool german() const { return m_language == QLatin1String("de"); } | |
| 49 | }; | ||
| 50 |