Skip to content

Commit 3768b78

Browse files
committed
fix: remove translation fallback values and hardcoded radius
- Remove all || 'fallback' patterns from pluginApi?.tr() calls - Replace hardcoded radius: 4 with radius: width / 2 for unread dot
1 parent 6e631ec commit 3768b78

4 files changed

Lines changed: 32 additions & 32 deletions

File tree

ntfy-notifications/BarWidget.qml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ Item {
7878

7979
onEntered: {
8080
var text = unreadCount > 0
81-
? (pluginApi?.tr("widget.tooltipWithCount") || "%1 unread").replace("%1", unreadCount)
82-
: (pluginApi?.tr("widget.tooltip") || "ntfy Notifications");
81+
? pluginApi?.tr("widget.tooltipWithCount").replace("%1", unreadCount)
82+
: pluginApi?.tr("widget.tooltip");
8383
TooltipService.show(root, text, BarService.getTooltipDirection());
8484
}
8585

ntfy-notifications/Main.qml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@ Item {
119119
try {
120120
parseMessages(xhr.responseText);
121121
} catch (e) {
122-
root.errorMessage = pluginApi?.tr("error.parse") || "Parse error";
122+
root.errorMessage = pluginApi?.tr("error.parse");
123123
Logger.e("[ntfy] Parse error:", e.toString());
124124
}
125125
} else if (xhr.status === 401 || xhr.status === 403) {
126-
root.errorMessage = pluginApi?.tr("error.auth") || "Auth failed";
126+
root.errorMessage = pluginApi?.tr("error.auth");
127127
Logger.w("[ntfy] Auth error:", xhr.status);
128128
} else if (xhr.status === 0) {
129-
root.errorMessage = pluginApi?.tr("error.network") || "Network error";
129+
root.errorMessage = pluginApi?.tr("error.network");
130130
Logger.w("[ntfy] Network error");
131131
} else {
132-
root.errorMessage = pluginApi?.tr("error.server") || "Server error";
132+
root.errorMessage = pluginApi?.tr("error.server");
133133
Logger.w("[ntfy] HTTP error:", xhr.status);
134134
}
135135

@@ -230,10 +230,10 @@ Item {
230230
function showToasts(newMessages) {
231231
if (newMessages.length === 1) {
232232
var msg = newMessages[0];
233-
var title = msg.title || msg.topic || pluginApi?.tr("toast.newMessage") || "ntfy";
233+
var title = msg.title || msg.topic || pluginApi?.tr("toast.newMessage");
234234
ToastService.showNotice(title, msg.message, "bell");
235235
} else if (newMessages.length > 1) {
236-
var countText = (pluginApi?.tr("toast.newMessages") || "%1 new notifications").replace("%1", newMessages.length);
236+
var countText = pluginApi?.tr("toast.newMessages").replace("%1", newMessages.length);
237237
ToastService.showNotice(countText, "", "bell");
238238
}
239239
}

ntfy-notifications/Panel.qml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ Item {
3636

3737
function priorityLabel(priority) {
3838
switch (priority) {
39-
case 1: return pluginApi?.tr("priority.min") || "Min"
40-
case 2: return pluginApi?.tr("priority.low") || "Low"
41-
case 3: return pluginApi?.tr("priority.default") || "Default"
42-
case 4: return pluginApi?.tr("priority.high") || "High"
43-
case 5: return pluginApi?.tr("priority.urgent") || "Urgent"
39+
case 1: return pluginApi?.tr("priority.min")
40+
case 2: return pluginApi?.tr("priority.low")
41+
case 3: return pluginApi?.tr("priority.default")
42+
case 4: return pluginApi?.tr("priority.high")
43+
case 5: return pluginApi?.tr("priority.urgent")
4444
default: return ""
4545
}
4646
}
@@ -50,17 +50,17 @@ Item {
5050
var now = Math.floor(Date.now() / 1000);
5151
var diff = now - unixTime;
5252

53-
if (diff < 60) return pluginApi?.tr("panel.timeNow") || "now";
53+
if (diff < 60) return pluginApi?.tr("panel.timeNow");
5454
if (diff < 3600) {
5555
var mins = Math.floor(diff / 60);
56-
return (pluginApi?.tr("panel.timeMinutes") || "%1m ago").replace("%1", mins);
56+
return pluginApi?.tr("panel.timeMinutes").replace("%1", mins);
5757
}
5858
if (diff < 86400) {
5959
var hours = Math.floor(diff / 3600);
60-
return (pluginApi?.tr("panel.timeHours") || "%1h ago").replace("%1", hours);
60+
return pluginApi?.tr("panel.timeHours").replace("%1", hours);
6161
}
6262
var days = Math.floor(diff / 86400);
63-
return (pluginApi?.tr("panel.timeDays") || "%1d ago").replace("%1", days);
63+
return pluginApi?.tr("panel.timeDays").replace("%1", days);
6464
}
6565

6666
Rectangle {
@@ -92,7 +92,7 @@ Item {
9292
}
9393

9494
NText {
95-
text: pluginApi?.tr("panel.title") || "ntfy Notifications"
95+
text: pluginApi?.tr("panel.title")
9696
pointSize: Style.fontSizeL
9797
font.weight: Style.fontWeightBold
9898
color: Color.mOnSurface
@@ -101,7 +101,7 @@ Item {
101101

102102
NIconButton {
103103
icon: "circle-check"
104-
tooltipText: pluginApi?.tr("panel.markAllRead") || "Mark all as read"
104+
tooltipText: pluginApi?.tr("panel.markAllRead")
105105
baseSize: Style.baseWidgetSize * 0.8
106106
onClicked: {
107107
if (main) main.markAllAsRead();
@@ -110,7 +110,7 @@ Item {
110110

111111
NIconButton {
112112
icon: "refresh"
113-
tooltipText: pluginApi?.tr("panel.refresh") || "Refresh"
113+
tooltipText: pluginApi?.tr("panel.refresh")
114114
baseSize: Style.baseWidgetSize * 0.8
115115
onClicked: {
116116
if (main) main.pollMessages();
@@ -119,7 +119,7 @@ Item {
119119

120120
NIconButton {
121121
icon: "x"
122-
tooltipText: pluginApi?.tr("panel.close") || "Close"
122+
tooltipText: pluginApi?.tr("panel.close")
123123
baseSize: Style.baseWidgetSize * 0.8
124124
onClicked: {
125125
if (pluginApi)
@@ -199,7 +199,7 @@ Item {
199199
}
200200

201201
NText {
202-
text: pluginApi?.tr("panel.loading") || "Loading..."
202+
text: pluginApi?.tr("panel.loading")
203203
pointSize: Style.fontSizeM
204204
color: Color.mOnSurfaceVariant
205205
Layout.alignment: Qt.AlignHCenter
@@ -228,14 +228,14 @@ Item {
228228
}
229229

230230
NText {
231-
text: pluginApi?.tr("panel.noTopics") || "No topics configured"
231+
text: pluginApi?.tr("panel.noTopics")
232232
pointSize: Style.fontSizeL
233233
color: Color.mOnSurfaceVariant
234234
Layout.alignment: Qt.AlignHCenter
235235
}
236236

237237
NText {
238-
text: pluginApi?.tr("panel.noTopicsHint") || "Open settings to add topics."
238+
text: pluginApi?.tr("panel.noTopicsHint")
239239
pointSize: Style.fontSizeS
240240
color: Color.mOnSurfaceVariant
241241
wrapMode: Text.Wrap
@@ -266,14 +266,14 @@ Item {
266266
}
267267

268268
NText {
269-
text: pluginApi?.tr("panel.empty") || "No notifications yet"
269+
text: pluginApi?.tr("panel.empty")
270270
pointSize: Style.fontSizeL
271271
color: Color.mOnSurfaceVariant
272272
Layout.alignment: Qt.AlignHCenter
273273
}
274274

275275
NText {
276-
text: pluginApi?.tr("panel.emptyHint") || "Notifications will appear here."
276+
text: pluginApi?.tr("panel.emptyHint")
277277
pointSize: Style.fontSizeS
278278
color: Color.mOnSurfaceVariant
279279
wrapMode: Text.Wrap
@@ -313,7 +313,7 @@ Item {
313313
visible: !messageItem.isRead
314314
width: 8
315315
height: 8
316-
radius: 4
316+
radius: width / 2
317317
color: Color.mPrimary
318318
Layout.alignment: Qt.AlignVCenter
319319
}
@@ -423,15 +423,15 @@ Item {
423423

424424
NButton {
425425
visible: modelData.click && modelData.click.length > 0
426-
text: pluginApi?.tr("panel.openLink") || "Open"
426+
text: pluginApi?.tr("panel.openLink")
427427
onClicked: Qt.openUrlExternally(modelData.click)
428428
}
429429

430430
Item { Layout.fillWidth: true }
431431

432432
NButton {
433433
visible: !messageItem.isRead
434-
text: pluginApi?.tr("panel.markRead") || "Mark read"
434+
text: pluginApi?.tr("panel.markRead")
435435
onClicked: {
436436
if (main) main.markAsRead(modelData.id);
437437
}

ntfy-notifications/Settings.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ ColumnLayout {
6868
description: pluginApi?.tr("settings.auth.desc")
6969
minimumWidth: 200
7070
model: [
71-
{ "key": "none", "name": pluginApi?.tr("settings.auth.none") || "None" },
72-
{ "key": "token", "name": pluginApi?.tr("settings.auth.token") || "Access Token" },
73-
{ "key": "basic", "name": pluginApi?.tr("settings.auth.basic") || "Username & Password" }
71+
{ "key": "none", "name": pluginApi?.tr("settings.auth.none") },
72+
{ "key": "token", "name": pluginApi?.tr("settings.auth.token") },
73+
{ "key": "basic", "name": pluginApi?.tr("settings.auth.basic") }
7474
]
7575
currentKey: root.editAuthMethod
7676
onSelected: key => {

0 commit comments

Comments
 (0)