From 6f3fed77d59227a9b3ec85d343ffb2443086f7fa Mon Sep 17 00:00:00 2001 From: Martin Klapetek Date: Wed, 18 Nov 2015 12:23:17 -0500 Subject: [PATCH] [calendar] Use ui language for getting the month name Simple QDate::longMonthName(..) won't do the job as it will return the month name using LC_DATE locale which is used for date formatting etc. So for example, in en_US locale and cs_CZ LC_DATE, it would return Czech month names while it should return English ones. So here we force the first ui language locale and take the month name from that. BUG: 353715 REVIEW: 125705 --- src/declarativeimports/calendar/calendar.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/declarativeimports/calendar/calendar.cpp b/src/declarativeimports/calendar/calendar.cpp index 693c032c7..5515550e9 100644 --- a/src/declarativeimports/calendar/calendar.cpp +++ b/src/declarativeimports/calendar/calendar.cpp @@ -184,7 +184,18 @@ QString Calendar::dayName(int weekday) const QString Calendar::monthName() const { - return QDate::longMonthName(m_displayedDate.month(), QDate::StandaloneFormat); + // Simple QDate::longMonthName won't do the job as it + // will return the month name using LC_DATE locale which is used + // for date formatting etc. So for example, in en_US locale + // and cs_CZ LC_DATE, it would return Czech month names while + // it should return English ones. So here we force the LANG + // locale and take the month name from that. + // + // See https://bugs.kde.org/show_bug.cgi?id=353715 + const QString lang = QLocale().uiLanguages().first(); + // If lang is empty, it will create just a system locale + QLocale langLocale(lang); + return langLocale.standaloneMonthName(m_displayedDate.month()); } int Calendar::year() const