[pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView
Timothy Nicholson
t.nicholson at proxmox.com
Fri Nov 8 13:52:54 CET 2024
With this patch, all systemd states and unit states in the service
view use gettext to be translated.
Signed-off-by: Timothy Nicholson <t.nicholson at proxmox.com>
---
As stated in the Bugzilla entry [0]: Up until now, only two
systemd states were translated. This patch changes this so all
systemd states use gettext and are translated. For some of the
states, translations need to be added.
[0]: https://bugzilla.proxmox.com/show_bug.cgi?id=5836
src/Utils.js | 11 +++++++++++
src/node/ServiceView.js | 14 ++++++--------
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/Utils.js b/src/Utils.js
index 7dd034a..23b0db5 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -305,6 +305,17 @@ utilities: {
return Ext.htmlEncode(username);
},
+ renderSystemdStatus: function(status) {
+ switch (status) {
+ case 'masked':
+ return gettext('disabled');
+ case 'not-found':
+ return gettext('not installed');
+ default:
+ return gettext(status);
+ }
+ },
+
getStoredAuth: function() {
let storedAuth = JSON.parse(window.localStorage.getItem('ProxmoxUser'));
return storedAuth || {};
diff --git a/src/node/ServiceView.js b/src/node/ServiceView.js
index 19cfc18..eb7fb01 100644
--- a/src/node/ServiceView.js
+++ b/src/node/ServiceView.js
@@ -180,14 +180,8 @@ Ext.define('Proxmox.node.ServiceView', {
sortable: true,
dataIndex: 'state',
renderer: (value, meta, rec) => {
- const unitState = rec.get('unit-state');
- if (unitState === 'masked') {
- return gettext('disabled');
- } else if (unitState === 'not-found') {
- return gettext('not installed');
- } else {
- return value;
- }
+ const state = rec.get('state');
+ return Proxmox.Utils.renderSystemdStatus(state);
},
},
{
@@ -203,6 +197,10 @@ Ext.define('Proxmox.node.ServiceView', {
sortable: true,
hidden: !Ext.Array.contains(['PVEAuthCookie', 'PBSAuthCookie'], Proxmox?.Setup?.auth_cookie_name),
dataIndex: 'unit-state',
+ renderer: (value, meta, rec) => {
+ const unitState = rec.get('unit-state');
+ return gettext(unitState);
+ }
},
{
header: gettext('Description'),
--
2.39.5
More information about the pve-devel
mailing list