* [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView
@ 2024-11-08 12:52 Timothy Nicholson
2024-11-08 13:02 ` Lukas Wagner
2024-11-08 13:04 ` Christoph Heiss
0 siblings, 2 replies; 3+ messages in thread
From: Timothy Nicholson @ 2024-11-08 12:52 UTC (permalink / raw)
To: pve-devel
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@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
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView
2024-11-08 12:52 [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView Timothy Nicholson
@ 2024-11-08 13:02 ` Lukas Wagner
2024-11-08 13:04 ` Christoph Heiss
1 sibling, 0 replies; 3+ messages in thread
From: Lukas Wagner @ 2024-11-08 13:02 UTC (permalink / raw)
To: Proxmox VE development discussion, Timothy Nicholson
Thanks for giving this a shot!
One comment inline
On 2024-11-08 13:52, Timothy Nicholson wrote:
> 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@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);
While the gettext function itself will gladly accept a string passed
in from a variable, the script extracting translatable strings [1] expects
a literal string that will be used as a reference for translations.
[1] https://git.proxmox.com/?p=proxmox-i18n.git;a=blob;f=jsgettext.pl;h=7f758fd9e5b3f5f7e0fb0c2ca0f46690df59dd58;hb=HEAD
--
- Lukas
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView
2024-11-08 12:52 [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView Timothy Nicholson
2024-11-08 13:02 ` Lukas Wagner
@ 2024-11-08 13:04 ` Christoph Heiss
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Heiss @ 2024-11-08 13:04 UTC (permalink / raw)
To: Timothy Nicholson; +Cc: Proxmox VE development discussion
On Fri, Nov 08, 2024 at 01:52:54PM +0100, Timothy Nicholson wrote:
> [..]
> 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');
Masked services are not the same as disabled, they have an important
difference in meaning, IMHO.
A *disabled* service does not start automatically on boot, but can still
be manually started using e.g. `systemctl start <name>.service`.
A *masked* service cannot even be started manually, so even stricter
than disabled.
> + case 'not-found':
> + return gettext('not installed');
> + default:
> + return gettext(status);
gettext() doesn't work that way, it needs the message as literal, as it
just extracts the given string in the argument.
See also proxmox-i18n/jsgettext.pl on how it works exactly.
So you'd need to switch-case each state individually (unfortunately).
> [..]
> @@ -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);
Same as above.
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-08 13:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-08 12:52 [pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView Timothy Nicholson
2024-11-08 13:02 ` Lukas Wagner
2024-11-08 13:04 ` Christoph Heiss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox