Skip to content

Add translation for stopped state notice#2337

Merged
frankiejol merged 7 commits into
UPC:mainfrom
Yago004:translate-days-notice
Jun 23, 2026
Merged

Add translation for stopped state notice#2337
frankiejol merged 7 commits into
UPC:mainfrom
Yago004:translate-days-notice

Conversation

@Yago004

@Yago004 Yago004 commented May 27, 2026

Copy link
Copy Markdown
Collaborator

Adds the translation for the notice that indicates since how many time has a machine been stopped.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR plumbs the user-facing locale ($c->stash->{i18n}) from the Mojolicious frontend through the WebSocket list_machines/list_machines_tree handlers down into Ravada::Front::list_domains, so the duration element of date_status_change (e.g. ["5", "minutes"] / ["now", ""]) is translated. It also adds the corresponding entries in en/es/ca .po files (plus "Virtual Machine locked" / "Show lock details") and contains an unrelated tweak to t/lib/Test/Ravada.pm that switches some removal requests from user_admin to Ravada::Utils::user_daemon.

Changes:

  • Pass i18n from the Mojolicious stash through Ravada::WebSocket::_list_machines into Ravada::Front::list_domains, where the new code localizes the count/unit pair under date_status_change->{duration}.
  • Add translations for minutes, year, month, week, day, hour, minute, now, Virtual Machine locked and Show lock details in en.po, es.po and ca.po.
  • Switch the user id used for remove_base/remove_domain requests in the test helper from user_admin to user_daemon (unrelated to the stated purpose).

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
script/rvd_front Passes i18n => $c->stash->{i18n} when subscribing to the WebSocket.
lib/Ravada/WebSocket.pm Requires i18n arg (via die) and forwards it as a filter to list_machines.
lib/Ravada/Front.pm Extracts i18n from args and localizes the duration tuple returned by _date_status_change; second branch lacks a ref() guard.
lib/Ravada/I18N/en.po New msgid/msgstr entries for time units and lock notices.
lib/Ravada/I18N/es.po Spanish translations for the new entries.
lib/Ravada/I18N/ca.po Catalan translations for the new entries.
t/lib/Test/Ravada.pm Switches removal requests in remove_domain_and_clones_req from user_admin to user_daemon (unrelated to PR purpose).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/Ravada/WebSocket.pm Outdated

sub _list_machines($rvd, $args) {
my $login = $args->{login} or die "Error: no login arg ".Dumper($args);
my $i18n = $args->{i18n} or die "Error: no i18n arg ".Dumper($args);
Comment thread lib/Ravada/Front.pm Outdated
Comment on lines +391 to +399
if (exists $row->{date_status_change}->{duration}
&& ref($row->{date_status_change}->{duration})
&& $row->{date_status_change}->{duration}->[0] =~ /^[a-z]+$/i
&& defined $i18n && $row->{date_status_change}->{duration}->[0]) {
$row->{date_status_change}->{duration}->[0] = $i18n->localize($row->{date_status_change}->{duration}->[0]);
}
if (defined $i18n && $row->{date_status_change}->{duration}->[1]) {
$row->{date_status_change}->{duration}->[1] = $i18n->localize($row->{date_status_change}->{duration}->[1]);
}
Comment thread t/lib/Test/Ravada.pm
Comment on lines +904 to +914
$req_rm = Ravada::Request->remove_base(
uid => Ravada::Utils::user_daemon->id
,id_domain => $domain->id)
if $domain->is_base;

my @after_req;
@after_req = ( after_request => $req_clone->id ) if $req_clone;
@after_req = ( after_request => $req_rm->id ) if $req_rm;
my $req= Ravada::Request->remove_domain(
name => $domain->name
,uid => user_admin->id
,uid => Ravada::Utils::user_daemon->id
Comment thread script/rvd_front Outdated
, login => $USER->name
, remote_ip => _remote_ip($c)
, client => _headers($c)
, i18n => $c->stash->{i18n}
Comment thread lib/Ravada/Front.pm Outdated
Comment on lines +391 to +399
if (exists $row->{date_status_change}->{duration}
&& ref($row->{date_status_change}->{duration})
&& $row->{date_status_change}->{duration}->[0] =~ /^[a-z]+$/i
&& defined $i18n && $row->{date_status_change}->{duration}->[0]) {
$row->{date_status_change}->{duration}->[0] = $i18n->localize($row->{date_status_change}->{duration}->[0]);
}
if (defined $i18n && $row->{date_status_change}->{duration}->[1]) {
$row->{date_status_change}->{duration}->[1] = $i18n->localize($row->{date_status_change}->{duration}->[1]);
}

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread lib/Ravada/I18N/ca.po Outdated
msgstr "Mostra detalls del bloqueig"

msgid "This virtual machine has no LDAP group restrictions."
msgstr "Aquesta màquina virtual no té restriccions de group LDAP."
Comment thread t/lib/Test/Ravada.pm
Comment on lines +904 to +914
$req_rm = Ravada::Request->remove_base(
uid => Ravada::Utils::user_daemon->id
,id_domain => $domain->id)
if $domain->is_base;

my @after_req;
@after_req = ( after_request => $req_clone->id ) if $req_clone;
@after_req = ( after_request => $req_rm->id ) if $req_rm;
my $req= Ravada::Request->remove_domain(
name => $domain->name
,uid => user_admin->id
,uid => Ravada::Utils::user_daemon->id
Comment thread lib/Ravada/WebSocket.pm Outdated
push @filter,("status" => "active") if $args->{show_active};

push @filter,("name" => $args->{show_name}) if $args->{show_name};
push @filter,("i18n" => $i18n);
Comment thread lib/Ravada/Front.pm Outdated
Comment on lines +346 to +347

my $i18n = delete $args{i18n};

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment thread script/rvd_front
Comment on lines 2202 to 2204
} elsif (!$user) {
$return = { error => "User not found" };
$return = { error => $i18n->localize("User not found") };
} else {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error here is translated but not cached, so it returns for each user localized correctly.

@frankiejol frankiejol merged commit 876ce5a into UPC:main Jun 23, 2026
1 check passed
@Yago004 Yago004 deleted the translate-days-notice branch June 26, 2026 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants