From 4136152f72e1db19eebef56f7932a976e291c1a0 Mon Sep 17 00:00:00 2001 From: myml Date: Fri, 27 Sep 2024 13:21:40 +0800 Subject: [PATCH] feat: cweekwidget uses locale to replace tr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cweekwidget组件使用locale.toString替换tr手动翻译 一来可以使用qt自己的翻译支持的语言更广泛, 且能减少翻译工作量 二来避免翻译人员在不知道显示场景下使用长翻译而不是缩写 Bug: https://pms.uniontech.com/bug-view-271483.html --- calendar-client/src/customWidget/cweekwidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/calendar-client/src/customWidget/cweekwidget.cpp b/calendar-client/src/customWidget/cweekwidget.cpp index 8ce21a8ca..12b30a11f 100644 --- a/calendar-client/src/customWidget/cweekwidget.cpp +++ b/calendar-client/src/customWidget/cweekwidget.cpp @@ -7,6 +7,7 @@ #include "constants.h" #include #include +#include CWeekWidget::CWeekWidget(QWidget *parent) : QPushButton(parent) , m_firstDay(CalendarManager::getInstance()->getFirstDayOfWeek()) @@ -69,7 +70,13 @@ void CWeekWidget::paintEvent(QPaintEvent *event) } QStringList weekStr; - weekStr << tr("Sun") << tr("Mon") << tr("Tue") << tr("Wed") << tr("Thu") << tr("Fri") << tr("Sat"); + for (int i = 0; i < 8; i++) { + // 2024/8/15 星期四是deepin23的发布日期 + // 减4是从周日开始将所有星期名字都写到weekStr,取代之前手动翻译方式 + QDate date(2024, 8, 15 - 4 + i); + QString weekDayName = locale.toString(date, "ddd"); + weekStr<