-
Notifications
You must be signed in to change notification settings - Fork 9
Work around standaloneDayName being incorrect in pt_PT #87
Conversation
This is a workaround for ubports/ubuntu-touch#510 Since the pt_PT locale has incorrect short day names, we can use the pt locale instead in this instance.
Can you also fix the CI issues here xD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple of nitpicks
qml/MonthComponent.qml
Outdated
property var day : { | ||
if (Qt.locale().name == "pt_PT") { | ||
// Workaround for https://github.com/ubports/ubuntu-touch/issues/510 | ||
Qt.locale("pt").standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.ShortFormat); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: When defining property bindings in { }
you should use the return
statement . See the second example here
qml/MonthComponent.qml
Outdated
} else { | ||
Qt.locale(Qt.locale().name).standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.ShortFormat); | ||
} | ||
} | ||
text: isYearView ? Qt.locale(Qt.locale().name).standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.NarrowFormat) : day |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than keep repeating the calls to Qt.locale().blah
in multiple places. It might be a bit cleaner to do something like
readonly property string localeName: Qt.locale().name === "pt_PT" ? "pt" : Qt.locale().name
text: Qt.locale(localeName).standaloneDayName(Qt.locale().firstDayOfWeek + index, isYearView ? Locale.NarrowFormat : Locale.ShortFormat);
What do you think?
qml/MonthComponent.qml
Outdated
@@ -338,7 +338,14 @@ Item{ | |||
id: weekDay | |||
objectName: "weekDay" + index | |||
width: parent.dayWidth | |||
property var day : Qt.locale(Qt.locale().name).standaloneDayName(( Qt.locale().firstDayOfWeek + index), Locale.ShortFormat); | |||
property var day : { | |||
if (Qt.locale().name == "pt_PT") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: Wrong indentation ;-)
We're trying to fix the underlying problem rather than working around it at ubports/system-settings#56 (comment). Stay tuned, I suppose. |
Fixing the underlying problem did not, in fact, work. Turns out that Qt assumes you mean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There, much better. :P |
This is a workaround for ubports/ubuntu-touch#510. It fixes half of the issue (the DateTime indicator uses another component).
Since the pt_PT locale has incorrect short day names, we can use the pt locale instead in this instance.
@dobey suggested that we remove
pt_PT
from our list of locales and instead usept
. However, it seems that the use of the specific locale was to work around QLocale("pt").nativeLanguageName() is "português do Brasil" in Qt.