mirror of
https://git.proxmox.com/git/proxmox-i18n
synced 2025-10-04 16:13:44 +00:00
js generator: move finding sources into method
less code directly executed in the global execution path makes the sources a bit easier to grasp and reason about. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
7b7a7598c0
commit
2bcbc73300
11
jsgettext.pl
11
jsgettext.pl
@ -44,15 +44,16 @@ if (my $base = $options->{b}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $sources = [];
|
sub find_js_sources {
|
||||||
|
my ($base_dirs) = @_;
|
||||||
|
|
||||||
my $find_cmd = 'find ';
|
my $find_cmd = 'find ';
|
||||||
# shell quote heuristic, with the (here safe) assumption that the dirs don't contain single-quotes
|
# shell quote heuristic, with the (here safe) assumption that the dirs don't contain single-quotes
|
||||||
$find_cmd .= join(' ', map { "'$_'" } $dirs->@*);
|
$find_cmd .= join(' ', map { "'$_'" } $base_dirs->@*);
|
||||||
$find_cmd .= ' -name "*.js"';
|
$find_cmd .= ' -name "*.js"';
|
||||||
open(my $find_cmd_output, '-|', "$find_cmd | sort") or die "Failed to execute command: $!";
|
open(my $find_cmd_output, '-|', "$find_cmd | sort") or die "Failed to execute command: $!";
|
||||||
|
|
||||||
# Iterate through the sorted output line by line
|
my $sources = [];
|
||||||
while (my $line = <$find_cmd_output>) {
|
while (my $line = <$find_cmd_output>) {
|
||||||
chomp $line;
|
chomp $line;
|
||||||
print "F: $line\n";
|
print "F: $line\n";
|
||||||
@ -60,6 +61,8 @@ while (my $line = <$find_cmd_output>) {
|
|||||||
}
|
}
|
||||||
close($find_cmd_output);
|
close($find_cmd_output);
|
||||||
|
|
||||||
|
return $sources;
|
||||||
|
}
|
||||||
|
|
||||||
my $header = <<__EOD;
|
my $header = <<__EOD;
|
||||||
Proxmox message catalog.
|
Proxmox message catalog.
|
||||||
@ -125,6 +128,8 @@ sub extract_msg {
|
|||||||
if !$count;
|
if !$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
my $sources = find_js_sources($dirs);
|
||||||
|
|
||||||
foreach my $s (@$sources) {
|
foreach my $s (@$sources) {
|
||||||
open(my $SRC_FH, '<', $s) || die "unable to open file '$s' - $!\n";
|
open(my $SRC_FH, '<', $s) || die "unable to open file '$s' - $!\n";
|
||||||
while(defined(my $line = <$SRC_FH>)) {
|
while(defined(my $line = <$SRC_FH>)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user