[pve-devel] [PATCH widget-toolkit] fix #5836: ui: translate systemd states in ServiceView

Christoph Heiss c.heiss at proxmox.com
Fri Nov 8 14:04:36 CET 2024


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.





More information about the pve-devel mailing list