mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-15 18:43:59 +00:00
Locale: fixed all Qt.locale calls to respect the user selected locale.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -5,10 +5,13 @@ import qs.Widgets
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
property var now
|
property var now
|
||||||
property color backgroundColor: Color.mPrimary
|
property color backgroundColor: Color.mPrimary
|
||||||
property color clockColor: Color.mOnPrimary
|
property color clockColor: Color.mOnPrimary
|
||||||
property color progressColor: Color.mError
|
property color progressColor: Color.mError
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
||||||
// Digital clock's seconds circular progress
|
// Digital clock's seconds circular progress
|
||||||
@@ -55,7 +58,7 @@ Item {
|
|||||||
|
|
||||||
NText {
|
NText {
|
||||||
text: {
|
text: {
|
||||||
var t = Settings.data.location.use12hourFormat ? Qt.locale().toString(now, "hh AP") : Qt.locale().toString(now, "HH")
|
var t = Settings.data.location.use12hourFormat ? locale.toString(now, "hh AP") : locale.toString(now, "HH")
|
||||||
return t.split(" ")[0]
|
return t.split(" ")[0]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import qs.Widgets
|
|||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
property ShellScreen screen
|
property ShellScreen screen
|
||||||
|
|
||||||
// Widget properties passed from Bar.qml for per-instance settings
|
// Widget properties passed from Bar.qml for per-instance settings
|
||||||
@@ -62,7 +63,7 @@ Rectangle {
|
|||||||
spacing: Settings.data.bar.showCapsule ? -4 : -2
|
spacing: Settings.data.bar.showCapsule ? -4 : -2
|
||||||
Repeater {
|
Repeater {
|
||||||
id: repeater
|
id: repeater
|
||||||
model: Qt.locale().toString(now, formatHorizontal.trim()).split("\\n")
|
model: locale.toString(now, formatHorizontal.trim()).split("\\n")
|
||||||
NText {
|
NText {
|
||||||
visible: text !== ""
|
visible: text !== ""
|
||||||
text: modelData
|
text: modelData
|
||||||
@@ -95,7 +96,7 @@ Rectangle {
|
|||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
spacing: -2
|
spacing: -2
|
||||||
Repeater {
|
Repeater {
|
||||||
model: Qt.locale().toString(now, formatVertical.trim()).split(" ")
|
model: locale.toString(now, formatVertical.trim()).split(" ")
|
||||||
delegate: NText {
|
delegate: NText {
|
||||||
visible: text !== ""
|
visible: text !== ""
|
||||||
text: modelData
|
text: modelData
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import qs.Widgets
|
|||||||
NBox {
|
NBox {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
|
|
||||||
property int forecastDays: 7
|
property int forecastDays: 7
|
||||||
readonly property bool weatherReady: Settings.data.location.weatherEnabled && (LocationService.data.weather !== null)
|
readonly property bool weatherReady: Settings.data.location.weatherEnabled && (LocationService.data.weather !== null)
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ NBox {
|
|||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
|
||||||
text: {
|
text: {
|
||||||
var weatherDate = new Date(LocationService.data.weather.daily.time[index].replace(/-/g, "/"))
|
var weatherDate = new Date(LocationService.data.weather.daily.time[index].replace(/-/g, "/"))
|
||||||
return Qt.locale().toString(weatherDate, "ddd")
|
return locale.toString(weatherDate, "ddd")
|
||||||
}
|
}
|
||||||
color: Color.mOnSurface
|
color: Color.mOnSurface
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ Loader {
|
|||||||
id: lockScreen
|
id: lockScreen
|
||||||
active: false
|
active: false
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
|
|
||||||
// Track if triggered via deprecated IPC call
|
// Track if triggered via deprecated IPC call
|
||||||
property bool triggeredViaDeprecatedCall: false
|
property bool triggeredViaDeprecatedCall: false
|
||||||
|
|
||||||
@@ -342,7 +344,7 @@ Loader {
|
|||||||
// Date below
|
// Date below
|
||||||
NText {
|
NText {
|
||||||
text: {
|
text: {
|
||||||
var lang = Qt.locale().name.split("_")[0]
|
var lang = locale.name.split("_")[0]
|
||||||
var formats = {
|
var formats = {
|
||||||
"de": "dddd, d. MMMM",
|
"de": "dddd, d. MMMM",
|
||||||
"es": "dddd, d 'de' MMMM",
|
"es": "dddd, d 'de' MMMM",
|
||||||
@@ -350,7 +352,7 @@ Loader {
|
|||||||
"pt": "dddd, d 'de' MMMM",
|
"pt": "dddd, d 'de' MMMM",
|
||||||
"zh": "yyyy年M月d日 dddd"
|
"zh": "yyyy年M月d日 dddd"
|
||||||
}
|
}
|
||||||
return Qt.locale().toString(Time.date, formats[lang] || "dddd, MMMM d")
|
return locale.toString(Time.date, formats[lang] || "dddd, MMMM d")
|
||||||
}
|
}
|
||||||
pointSize: Style.fontSizeXL
|
pointSize: Style.fontSizeXL
|
||||||
font.weight: Font.Medium
|
font.weight: Font.Medium
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ ColumnLayout {
|
|||||||
spacing: Style.marginM
|
spacing: Style.marginM
|
||||||
width: 700
|
width: 700
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
|
|
||||||
// Properties to receive data from parent
|
// Properties to receive data from parent
|
||||||
property var widgetData: null
|
property var widgetData: null
|
||||||
property var widgetMetadata: null
|
property var widgetMetadata: null
|
||||||
@@ -200,7 +202,7 @@ ColumnLayout {
|
|||||||
// Horizontal
|
// Horizontal
|
||||||
Repeater {
|
Repeater {
|
||||||
Layout.topMargin: Style.marginM
|
Layout.topMargin: Style.marginM
|
||||||
model: Qt.locale().toString(now, valueFormatHorizontal.trim()).split("\\n")
|
model: locale.toString(now, valueFormatHorizontal.trim()).split("\\n")
|
||||||
delegate: NText {
|
delegate: NText {
|
||||||
visible: text !== ""
|
visible: text !== ""
|
||||||
text: modelData
|
text: modelData
|
||||||
@@ -231,7 +233,7 @@ ColumnLayout {
|
|||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
Layout.topMargin: Style.marginM
|
Layout.topMargin: Style.marginM
|
||||||
model: Qt.locale().toString(now, valueFormatVertical.trim()).split(" ")
|
model: locale.toString(now, valueFormatVertical.trim()).split(" ")
|
||||||
delegate: NText {
|
delegate: NText {
|
||||||
visible: text !== ""
|
visible: text !== ""
|
||||||
text: modelData
|
text: modelData
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ ColumnLayout {
|
|||||||
id: root
|
id: root
|
||||||
spacing: Style.marginL
|
spacing: Style.marginL
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
|
|
||||||
NHeader {
|
NHeader {
|
||||||
label: I18n.tr("settings.location.location.section.label")
|
label: I18n.tr("settings.location.location.section.label")
|
||||||
description: I18n.tr("settings.location.location.section.description")
|
description: I18n.tr("settings.location.location.section.description")
|
||||||
@@ -135,15 +137,15 @@ ColumnLayout {
|
|||||||
"name": I18n.tr("settings.location.date-time.first-day-of-week.automatic")
|
"name": I18n.tr("settings.location.date-time.first-day-of-week.automatic")
|
||||||
}, {
|
}, {
|
||||||
"key": "6",
|
"key": "6",
|
||||||
"name": Qt.locale().dayName(6, Locale.LongFormat)
|
"name": locale.dayName(6, Locale.LongFormat)
|
||||||
}, // Saturday
|
}, // Saturday
|
||||||
{
|
{
|
||||||
"key": "0",
|
"key": "0",
|
||||||
"name": Qt.locale().dayName(0, Locale.LongFormat)
|
"name": locale.dayName(0, Locale.LongFormat)
|
||||||
}, // Sunday
|
}, // Sunday
|
||||||
{
|
{
|
||||||
"key": "1",
|
"key": "1",
|
||||||
"name": Qt.locale().dayName(1, Locale.LongFormat)
|
"name": locale.dayName(1, Locale.LongFormat)
|
||||||
} // Monday
|
} // Monday
|
||||||
]
|
]
|
||||||
onSelected: key => Settings.data.location.firstDayOfWeek = parseInt(key)
|
onSelected: key => Settings.data.location.firstDayOfWeek = parseInt(key)
|
||||||
|
|||||||
@@ -5,16 +5,17 @@ import qs.Commons
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
|
property var locale: I18n.langCode ? Qt.locale(I18n.langCode) : Qt.locale()
|
||||||
|
property date sampleDate: new Date() // Dec 25, 2023, 2:30:45.123 PM
|
||||||
|
|
||||||
|
signal tokenClicked(string token)
|
||||||
|
|
||||||
color: Color.mSurface
|
color: Color.mSurface
|
||||||
border.color: Color.mOutline
|
border.color: Color.mOutline
|
||||||
border.width: Style.borderS
|
border.width: Style.borderS
|
||||||
radius: Style.radiusM
|
radius: Style.radiusM
|
||||||
|
|
||||||
property date sampleDate: new Date() // Dec 25, 2023, 2:30:45.123 PM
|
|
||||||
|
|
||||||
// Signal emitted when a token is clicked
|
|
||||||
signal tokenClicked(string token)
|
|
||||||
|
|
||||||
ColumnLayout {
|
ColumnLayout {
|
||||||
id: column
|
id: column
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@@ -312,7 +313,7 @@ Rectangle {
|
|||||||
|
|
||||||
NText {
|
NText {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: Qt.locale().toString(root.sampleDate, modelData.token)
|
text: locale.toString(root.sampleDate, modelData.token)
|
||||||
color: tokenMouseArea.containsMouse ? Color.mOnPrimary : Color.mSurfaceVariant
|
color: tokenMouseArea.containsMouse ? Color.mOnPrimary : Color.mSurfaceVariant
|
||||||
pointSize: Style.fontSizeS
|
pointSize: Style.fontSizeS
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user