Skip to content

Commit 3b4f4c2

Browse files
committed
fix(ntfy-notifications): use Logger tag syntax and translation interpolations
- Use Logger.x("ntfy", ...) instead of Logger.x("[ntfy] ...") - Replace .replace("%1", val) with pluginApi?.tr(key, { count: val }) - Update i18n strings to use {count} interpolation
1 parent f44514a commit 3b4f4c2

5 files changed

Lines changed: 20 additions & 20 deletions

File tree

ntfy-notifications/BarWidget.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Item {
7878

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

ntfy-notifications/Main.qml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,17 @@ Item {
120120
parseMessages(xhr.responseText);
121121
} catch (e) {
122122
root.errorMessage = pluginApi?.tr("error.parse");
123-
Logger.e("[ntfy] Parse error:", e.toString());
123+
Logger.e("ntfy", "Parse error:", e.toString());
124124
}
125125
} else if (xhr.status === 401 || xhr.status === 403) {
126126
root.errorMessage = pluginApi?.tr("error.auth");
127-
Logger.w("[ntfy] Auth error:", xhr.status);
127+
Logger.w("ntfy", "Auth error:", xhr.status);
128128
} else if (xhr.status === 0) {
129129
root.errorMessage = pluginApi?.tr("error.network");
130-
Logger.w("[ntfy] Network error");
130+
Logger.w("ntfy", "Network error");
131131
} else {
132132
root.errorMessage = pluginApi?.tr("error.server");
133-
Logger.w("[ntfy] HTTP error:", xhr.status);
133+
Logger.w("ntfy", "HTTP error:", xhr.status);
134134
}
135135

136136
root.isLoading = false;
@@ -181,7 +181,7 @@ Item {
181181
});
182182
} catch (e) {
183183
// Skip malformed lines
184-
Logger.d("[ntfy] Skipping malformed line:", line);
184+
Logger.d("ntfy", "Skipping malformed line:", line);
185185
}
186186
}
187187

@@ -233,7 +233,7 @@ Item {
233233
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").replace("%1", newMessages.length);
236+
var countText = pluginApi?.tr("toast.newMessages", { count: newMessages.length });
237237
ToastService.showNotice(countText, "", "bell");
238238
}
239239
}

ntfy-notifications/Panel.qml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ Item {
5353
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").replace("%1", mins);
56+
return pluginApi?.tr("panel.timeMinutes", { count: mins });
5757
}
5858
if (diff < 86400) {
5959
var hours = Math.floor(diff / 3600);
60-
return pluginApi?.tr("panel.timeHours").replace("%1", hours);
60+
return pluginApi?.tr("panel.timeHours", { count: hours });
6161
}
6262
var days = Math.floor(diff / 86400);
63-
return pluginApi?.tr("panel.timeDays").replace("%1", days);
63+
return pluginApi?.tr("panel.timeDays", { count: days });
6464
}
6565

6666
Rectangle {

ntfy-notifications/i18n/de.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"widget": {
33
"tooltip": "ntfy Benachrichtigungen",
4-
"tooltipWithCount": "%1 ungelesene Benachrichtigungen",
4+
"tooltipWithCount": "{count} ungelesene Benachrichtigungen",
55
"noMessages": "Keine Benachrichtigungen"
66
},
77
"menu": {
@@ -24,9 +24,9 @@
2424
"topic": "Topic",
2525
"priority": "Priorität",
2626
"timeNow": "jetzt",
27-
"timeMinutes": "vor %1 Min.",
28-
"timeHours": "vor %1 Std.",
29-
"timeDays": "vor %1 Tagen"
27+
"timeMinutes": "vor {count} Min.",
28+
"timeHours": "vor {count} Std.",
29+
"timeDays": "vor {count} Tagen"
3030
},
3131
"settings": {
3232
"server": {
@@ -71,7 +71,7 @@
7171
},
7272
"toast": {
7373
"newMessage": "Neue ntfy Benachrichtigung",
74-
"newMessages": "%1 neue Benachrichtigungen"
74+
"newMessages": "{count} neue Benachrichtigungen"
7575
},
7676
"error": {
7777
"network": "Netzwerkfehler",

ntfy-notifications/i18n/en.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"widget": {
33
"tooltip": "ntfy Notifications",
4-
"tooltipWithCount": "%1 unread notifications",
4+
"tooltipWithCount": "{count} unread notifications",
55
"noMessages": "No notifications"
66
},
77
"menu": {
@@ -24,9 +24,9 @@
2424
"topic": "Topic",
2525
"priority": "Priority",
2626
"timeNow": "now",
27-
"timeMinutes": "%1m ago",
28-
"timeHours": "%1h ago",
29-
"timeDays": "%1d ago"
27+
"timeMinutes": "{count}m ago",
28+
"timeHours": "{count}h ago",
29+
"timeDays": "{count}d ago"
3030
},
3131
"settings": {
3232
"server": {
@@ -71,7 +71,7 @@
7171
},
7272
"toast": {
7373
"newMessage": "New ntfy notification",
74-
"newMessages": "%1 new notifications"
74+
"newMessages": "{count} new notifications"
7575
},
7676
"error": {
7777
"network": "Network error",

0 commit comments

Comments
 (0)