Skip to content

Add translation for stopped state notice#2337

Open
Yago004 wants to merge 2 commits into
UPC:mainfrom
Yago004:translate-days-notice
Open

Add translation for stopped state notice#2337
Yago004 wants to merge 2 commits into
UPC:mainfrom
Yago004:translate-days-notice

Conversation

@Yago004
Copy link
Copy Markdown
Collaborator

@Yago004 Yago004 commented May 27, 2026

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

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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

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
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
, login => $USER->name
, remote_ip => _remote_ip($c)
, client => _headers($c)
, i18n => $c->stash->{i18n}
Comment thread lib/Ravada/Front.pm
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]);
}
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