Skip to content

Commit

Permalink
Refactor success notification messages to use template strings for be…
Browse files Browse the repository at this point in the history
…tter localization support
  • Loading branch information
daniele-mng committed Mar 7, 2025
1 parent a0ba9b9 commit f48c9de
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 37 deletions.
14 changes: 7 additions & 7 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"{{first}} - {{last}} of {{filtered}}": "{{first}} - {{last}} von {{filtered}}",
"{{hosts}} Host(s) with average severity {{avgSev}}": "{{hosts}} Host(s) mit durchschnittlichem Schweregrad {{avgSev}}",
"{{hours}}:{{minutes}} h": "{{hours}}:{{minutes}} h",
"{{name}} cloned successfully.": "{{name}} erfolgreich geklont.",
"{{name}} deleted successfully.": "{{name}} erfolgreich gelöscht.",
"{{name}} downloaded successfully.": "{{name}} erfolgreich heruntergeladen.",
"{{name}} restored successfully.": "{{name}} erfolgreich wiederhergestellt.",
"{{name}} Start: {{date}}": "{{name}} Start: {{date}}",
"{{name}} Start: {{startdate}} End: {{enddate}}": "{{name}} Start: {{startdate}} Ende: {{enddate}}",
"{{nr}} more times": "{{nr}} weitere Male",
Expand Down Expand Up @@ -357,7 +361,6 @@
"Clone Target": "Ziel klonen",
"Clone Ticket": "Ticket klonen",
"Clone User": "Benutzer klonen",
"cloned successfully.": "erfolgreich geklont.",
"Close": "Schließen",
"Closed": "Geschlossen",
"Closed CVEs": "Geschlossene CVEs",
Expand Down Expand Up @@ -538,7 +541,6 @@
"Delete Requested": "Löschen Angefragt",
"Delete selection": "Auswahl löschen",
"Delete TLS Certificate": "TLS-Zertifikat löschen",
"deleted successfully.": "erfolgreich gelöscht.",
"Delta": "Delta",
"Delta Report": "Delta-Bericht",
"Delta Results": "Delta-Ergebnisse",
Expand Down Expand Up @@ -583,7 +585,6 @@
"Download TLS Certificate": "TLS-Zertifikat herunterladen",
"Download TLS Certificate as .pem": "TLS-Zertifikat als .pem herunterladen",
"Download Windows Executable (.exe)": "Windows-Programmdatei (.exe) herunterladen",
"downloaded successfully.": "erfolgreich heruntergeladen.",
"Duration": "Laufzeit",
"Duration of last Scan": "Dauer des letzten Scans",
"Dynamic": "Dynamisch",
Expand Down Expand Up @@ -1446,7 +1447,6 @@
"Resource Type": "Ressourcen-Typ",
"Resources": "Ressourcen",
"Restore": "Wiederherstellen",
"restored successfully.": "erfolgreich wiederhergestellt.",
"Result": "Ergebnis",
"Result 1": "Ergebnis 1",
"Result 2": "Ergebnis 2",
Expand Down Expand Up @@ -1474,7 +1474,6 @@
"Results with the severity \"Medium\" are currently included.": "Ergebnisse mit dem Schweregrad \"Mittel\" werden derzeit miteinbezogen.",
"Resume": "Fortsetzen",
"Resume Requested": "Fortsetzen angefragt",
"resumed successfully.": "erfolgreich fortgesetzt.",
"Reverse": "Rückwärts",
"Reverse Lookup Only": "Nur Invers-Lookup",
"Reverse Lookup Unify": "Invers-Lookup-Vereinheitlichung",
Expand Down Expand Up @@ -1634,15 +1633,13 @@
"Start Task": "Aufgabe starten",
"Start this scan task right away": "Diese Scanaufgabe direkt starten",
"Start Time": "Startzeit",
"started successfully.": "erfolgreich gestartet.",
"Static": "Statisch",
"Status": "Status",
"Status Details": "Statusdetails",
"Still in use": "Noch in Gebrauch",
"Stop": "Stop",
"Stop Requested": "Stopp angefragt",
"Stopped": "Angehalten",
"stopped successfully.": "erfolgreich angehalten.",
"Store as default": "Als Standard speichern",
"Store filter as: ": "Filter speichern als: ",
"Store indicated settings (without filter) as default": "Einstellungen (ohne Filter) als Standard speichern",
Expand Down Expand Up @@ -1734,6 +1731,9 @@
"Targets using this Port List": "Ziele, die diese Portliste verwenden",
"task": "Aufgabe",
"Task": "Aufgabe",
"Task {{name}} resumed successfully.": "Aufgabe {{name}} erfolgreich fortgesetzt.",
"Task {{name}} started successfully.": "Aufgabe {{name}} erfolgreich gestartet.",
"Task {{name}} stopped successfully.": "Aufgabe {{name}} erfolgreich angehalten.",
"Task is alterable": "Aufgabe ist änderbar",
"Task is configured to run on sensor {{name}}": "Aufgabe ist konfiguriert, um auf dem Sensor {{name}} ausgeführt zu werden",
"Task is queued for scanning": "Aufgabe ist in der Warteschlange zum Scannen",
Expand Down
14 changes: 7 additions & 7 deletions public/locales/gsa-en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"{{first}} - {{last}} of {{filtered}}": "{{first}} - {{last}} of {{filtered}}",
"{{hosts}} Host(s) with average severity {{avgSev}}": "{{hosts}} Host(s) with average severity {{avgSev}}",
"{{hours}}:{{minutes}} h": "{{hours}}:{{minutes}} h",
"{{name}} cloned successfully.": "{{name}} cloned successfully.",
"{{name}} deleted successfully.": "{{name}} deleted successfully.",
"{{name}} downloaded successfully.": "{{name}} downloaded successfully.",
"{{name}} restored successfully.": "{{name}} restored successfully.",
"{{name}} Start: {{date}}": "{{name}} Start: {{date}}",
"{{name}} Start: {{startdate}} End: {{enddate}}": "{{name}} Start: {{startdate}} End: {{enddate}}",
"{{nr}} more times": "{{nr}} more times",
Expand Down Expand Up @@ -357,7 +361,6 @@
"Clone Target": "Clone Target",
"Clone Ticket": "Clone Ticket",
"Clone User": "Clone User",
"cloned successfully.": "cloned successfully.",
"Close": "Close",
"Closed": "Closed",
"Closed CVEs": "Closed CVEs",
Expand Down Expand Up @@ -538,7 +541,6 @@
"Delete Requested": "Delete Requested",
"Delete selection": "Delete selection",
"Delete TLS Certificate": "Delete TLS Certificate",
"deleted successfully.": "deleted successfully.",
"Delta": "Delta",
"Delta Report": "Delta Report",
"Delta Results": "Delta Results",
Expand Down Expand Up @@ -583,7 +585,6 @@
"Download TLS Certificate": "Download TLS Certificate",
"Download TLS Certificate as .pem": "Download TLS Certificate as .pem",
"Download Windows Executable (.exe)": "Download Windows Executable (.exe)",
"downloaded successfully.": "downloaded successfully.",
"Duration": "Duration",
"Duration of last Scan": "Duration of last Scan",
"Dynamic": "Dynamic",
Expand Down Expand Up @@ -1446,7 +1447,6 @@
"Resource Type": "Resource Type",
"Resources": "Resources",
"Restore": "Restore",
"restored successfully.": "restored successfully.",
"Result": "Result",
"Result 1": "Result 1",
"Result 2": "Result 2",
Expand Down Expand Up @@ -1474,7 +1474,6 @@
"Results with the severity \"Medium\" are currently included.": "Results with the severity \"Medium\" are currently included.",
"Resume": "Resume",
"Resume Requested": "Resume Requested",
"resumed successfully.": "resumed successfully.",
"Reverse": "Reverse",
"Reverse Lookup Only": "Reverse Lookup Only",
"Reverse Lookup Unify": "Reverse Lookup Unify",
Expand Down Expand Up @@ -1634,15 +1633,13 @@
"Start Task": "Start Task",
"Start this scan task right away": "Start this scan task right away",
"Start Time": "Start Time",
"started successfully.": "started successfully.",
"Static": "Static",
"Status": "Status",
"Status Details": "Status Details",
"Still in use": "Still in use",
"Stop": "Stop",
"Stop Requested": "Stop Requested",
"Stopped": "Stopped",
"stopped successfully.": "stopped successfully.",
"Store as default": "Store as default",
"Store filter as: ": "Store filter as: ",
"Store indicated settings (without filter) as default": "Store indicated settings (without filter) as default",
Expand Down Expand Up @@ -1734,6 +1731,9 @@
"Targets using this Port List": "Targets using this Port List",
"task": "task",
"Task": "Task",
"Task {{name}} resumed successfully.": "Task {{name}} resumed successfully.",
"Task {{name}} started successfully.": "Task {{name}} started successfully.",
"Task {{name}} stopped successfully.": "Task {{name}} stopped successfully.",
"Task is alterable": "Task is alterable",
"Task is configured to run on sensor {{name}}": "Task is configured to run on sensor {{name}}",
"Task is queued for scanning": "Task is queued for scanning",
Expand Down
14 changes: 7 additions & 7 deletions public/locales/gsa-zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"{{first}} - {{last}} of {{filtered}}": "{{first}} - {{last}} / {{filtered}}",
"{{hosts}} Host(s) with average severity {{avgSev}}": "{{hosts}} 主机平均严重性 {{avgSev}}",
"{{hours}}:{{minutes}} h": "{{hours}}:{{minutes}}",
"{{name}} cloned successfully.": "",
"{{name}} deleted successfully.": "",
"{{name}} downloaded successfully.": "",
"{{name}} restored successfully.": "",
"{{name}} Start: {{date}}": "{{name}} 开始: {{date}}",
"{{name}} Start: {{startdate}} End: {{enddate}}": "{{name}} 开始: {{startdate}} 结束: {{enddate}}",
"{{nr}} more times": "{{nr}} more times",
Expand Down Expand Up @@ -357,7 +361,6 @@
"Clone Target": "复制扫描目标",
"Clone Ticket": "复制工单",
"Clone User": "复制用户",
"cloned successfully.": "",
"Close": "关闭",
"Closed": "关闭",
"Closed CVEs": "已关闭的CVEs",
Expand Down Expand Up @@ -538,7 +541,6 @@
"Delete Requested": "删除请求",
"Delete selection": "",
"Delete TLS Certificate": "删除TLS证书",
"deleted successfully.": "",
"Delta": "Delta",
"Delta Report": "Delta报告",
"Delta Results": "Delta报告",
Expand Down Expand Up @@ -583,7 +585,6 @@
"Download TLS Certificate": "下载TLS证书",
"Download TLS Certificate as .pem": "下载pem格式TLS证书",
"Download Windows Executable (.exe)": "下载Windows可执行程序 (.exe)",
"downloaded successfully.": "",
"Duration": "持续时间",
"Duration of last Scan": "上次扫描持续时间",
"Dynamic": "动态",
Expand Down Expand Up @@ -1446,7 +1447,6 @@
"Resource Type": "资源类型",
"Resources": "资源",
"Restore": "恢复",
"restored successfully.": "",
"Result": "扫描结果",
"Result 1": "结果 1",
"Result 2": "结果 2",
Expand Down Expand Up @@ -1474,7 +1474,6 @@
"Results with the severity \"Medium\" are currently included.": "目前包括严重性为\"中危\"的结果.",
"Resume": "继续",
"Resume Requested": "恢复请求",
"resumed successfully.": "",
"Reverse": "反向",
"Reverse Lookup Only": "",
"Reverse Lookup Unify": "",
Expand Down Expand Up @@ -1634,15 +1633,13 @@
"Start Task": "启动任务",
"Start this scan task right away": "立即启动此任务",
"Start Time": "启动时间",
"started successfully.": "",
"Static": "静态",
"Status": "状态",
"Status Details": "状态详情",
"Still in use": "仍在使用",
"Stop": "停止",
"Stop Requested": "请求终止",
"Stopped": "已停止",
"stopped successfully.": "",
"Store as default": "默认排序",
"Store filter as: ": "存储过滤器至: ",
"Store indicated settings (without filter) as default": "将指示的设置(无筛选)存储为默认值",
Expand Down Expand Up @@ -1734,6 +1731,9 @@
"Targets using this Port List": "使用此端口列表的扫描目标",
"task": "任务",
"Task": "任务",
"Task {{name}} resumed successfully.": "",
"Task {{name}} started successfully.": "",
"Task {{name}} stopped successfully.": "",
"Task is alterable": "任务是可变的",
"Task is configured to run on sensor {{name}}": "任务配置为在传感器{{name}}上运行",
"Task is queued for scanning": "任务已进入等待扫描队列",
Expand Down
14 changes: 7 additions & 7 deletions public/locales/gsa-zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"{{first}} - {{last}} of {{filtered}}": "",
"{{hosts}} Host(s) with average severity {{avgSev}}": "",
"{{hours}}:{{minutes}} h": "",
"{{name}} cloned successfully.": "",
"{{name}} deleted successfully.": "",
"{{name}} downloaded successfully.": "",
"{{name}} restored successfully.": "",
"{{name}} Start: {{date}}": "",
"{{name}} Start: {{startdate}} End: {{enddate}}": "",
"{{nr}} more times": "",
Expand Down Expand Up @@ -357,7 +361,6 @@
"Clone Target": "再製目標",
"Clone Ticket": "",
"Clone User": "再製使用者",
"cloned successfully.": "",
"Close": "",
"Closed": "",
"Closed CVEs": "",
Expand Down Expand Up @@ -538,7 +541,6 @@
"Delete Requested": "",
"Delete selection": "",
"Delete TLS Certificate": "TLS 憑證",
"deleted successfully.": "",
"Delta": "",
"Delta Report": "",
"Delta Results": "",
Expand Down Expand Up @@ -583,7 +585,6 @@
"Download TLS Certificate": "下載 TLS 憑證",
"Download TLS Certificate as .pem": "下載 TLS 憑證",
"Download Windows Executable (.exe)": "",
"downloaded successfully.": "",
"Duration": "期間",
"Duration of last Scan": "",
"Dynamic": "",
Expand Down Expand Up @@ -1446,7 +1447,6 @@
"Resource Type": "",
"Resources": "資源",
"Restore": "還原",
"restored successfully.": "",
"Result": "結果",
"Result 1": "結果",
"Result 2": "結果",
Expand Down Expand Up @@ -1474,7 +1474,6 @@
"Results with the severity \"Medium\" are currently included.": "",
"Resume": "",
"Resume Requested": "",
"resumed successfully.": "",
"Reverse": "",
"Reverse Lookup Only": "",
"Reverse Lookup Unify": "",
Expand Down Expand Up @@ -1634,15 +1633,13 @@
"Start Task": "開始作業",
"Start this scan task right away": "",
"Start Time": "開始時間",
"started successfully.": "",
"Static": "",
"Status": "狀態",
"Status Details": "",
"Still in use": "",
"Stop": "",
"Stop Requested": "",
"Stopped": "已停止",
"stopped successfully.": "",
"Store as default": "儲存為預設值",
"Store filter as: ": "",
"Store indicated settings (without filter) as default": "",
Expand Down Expand Up @@ -1734,6 +1731,9 @@
"Targets using this Port List": "",
"task": "",
"Task": "作業",
"Task {{name}} resumed successfully.": "",
"Task {{name}} started successfully.": "",
"Task {{name}} stopped successfully.": "",
"Task is alterable": "",
"Task is configured to run on sensor {{name}}": "",
"Task is queued for scanning": "",
Expand Down
2 changes: 1 addition & 1 deletion src/web/entities/Container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class EntitiesContainer extends React.Component {
deleteEntity(entity.id),
this.handleChanged,
this.handleError,
`${entity.name} ${_('deleted successfully.')}`,
_('{{name}} deleted successfully.', {name: entity.name}),
);

Check warning on line 158 in src/web/entities/Container.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/entities/Container.jsx#L153-L158

Added lines #L153 - L158 were not covered by tests
}

Expand Down
6 changes: 3 additions & 3 deletions src/web/entity/EntityComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const EntityComponent = ({
onDownloaded({filename, data: response.data});
showSuccessNotification(
'',
`${entity.name} ${_('downloaded successfully.')}`,
_('{{name}} downloaded successfully.', {name: entity.name}),
);
}
} catch (error) {
Expand All @@ -124,7 +124,7 @@ const EntityComponent = ({
deleteEntity(entity),
onDeleted,
onDeleteError,
`${entity.name} ${_('deleted successfully.')}`,
_('{{name}} deleted successfully.', {name: entity.name}),
);
};

Expand All @@ -135,7 +135,7 @@ const EntityComponent = ({
cmd.clone(entity),
onCloned,
onCloneError,
`${entity.name} ${_('cloned successfully.')}`,
_('{{name}} cloned successfully.', {name: entity.name}),
);
};

Expand Down
8 changes: 6 additions & 2 deletions src/web/pages/extras/TrashCanPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,9 @@ const TrashCan = () => {
try {
await gmp.trashcan.restore(entity);
loadTrash();
showSuccessNotification(`${entity.name} ${_('restored successfully.')}`);
showSuccessNotification(
_('{{name}} restored successfully.', {name: entity.name}),
);
} catch (error) {
showError(error);
}

Check warning on line 341 in src/web/pages/extras/TrashCanPage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/extras/TrashCanPage.jsx#L333-L341

Added lines #L333 - L341 were not covered by tests
Expand All @@ -345,7 +347,9 @@ const TrashCan = () => {
try {
await gmp.trashcan.delete(entity);
loadTrash();
showSuccessNotification(`${entity.name} ${_('deleted successfully.')}`);
showSuccessNotification(
_('{{name}} deleted successfully.', {name: entity.name}),
);
} catch (error) {
showError(error);
}

Check warning on line 355 in src/web/pages/extras/TrashCanPage.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/extras/TrashCanPage.jsx#L347-L355

Added lines #L347 - L355 were not covered by tests
Expand Down
6 changes: 3 additions & 3 deletions src/web/pages/tasks/Component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class TaskComponent extends React.Component {
this.cmd.start(task),
onStarted,
onStartError,
`${task.name} ${_('started successfully.')}`,
_('Task {{name}} started successfully.', {name: task.name}),
);
}

Expand All @@ -169,7 +169,7 @@ class TaskComponent extends React.Component {
this.cmd.stop(task),
onStopped,
onStopError,
`${task.name} ${_('stopped successfully.')}`,
_('Task {{name}} stopped successfully.', {name: task.name}),
);

Check warning on line 173 in src/web/pages/tasks/Component.jsx

View check run for this annotation

Codecov / codecov/patch

src/web/pages/tasks/Component.jsx#L168-L173

Added lines #L168 - L173 were not covered by tests
}

Expand All @@ -182,7 +182,7 @@ class TaskComponent extends React.Component {
this.cmd.resume(task),
onResumed,
onResumeError,
`${task.name} ${_('resumed successfully.')}`,
_('Task {{name}} resumed successfully.', {name: task.name}),
);
}

Expand Down

0 comments on commit f48c9de

Please sign in to comment.