mirror of
https://git.proxmox.com/git/proxmox-i18n
synced 2025-10-04 09:48:12 +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
25
jsgettext.pl
25
jsgettext.pl
@ -44,22 +44,25 @@ if (my $base = $options->{b}) {
|
||||
}
|
||||
}
|
||||
|
||||
my $sources = [];
|
||||
sub find_js_sources {
|
||||
my ($base_dirs) = @_;
|
||||
|
||||
my $find_cmd = 'find ';
|
||||
# shell quote heuristic, with the (here safe) assumption that the dirs don't contain single-quotes
|
||||
$find_cmd .= join(' ', map { "'$_'" } $dirs->@*);
|
||||
$find_cmd .= ' -name "*.js"';
|
||||
open(my $find_cmd_output, '-|', "$find_cmd | sort") or die "Failed to execute command: $!";
|
||||
my $find_cmd = 'find ';
|
||||
# shell quote heuristic, with the (here safe) assumption that the dirs don't contain single-quotes
|
||||
$find_cmd .= join(' ', map { "'$_'" } $base_dirs->@*);
|
||||
$find_cmd .= ' -name "*.js"';
|
||||
open(my $find_cmd_output, '-|', "$find_cmd | sort") or die "Failed to execute command: $!";
|
||||
|
||||
# Iterate through the sorted output line by line
|
||||
while (my $line = <$find_cmd_output>) {
|
||||
my $sources = [];
|
||||
while (my $line = <$find_cmd_output>) {
|
||||
chomp $line;
|
||||
print "F: $line\n";
|
||||
push @$sources, $line;
|
||||
}
|
||||
close($find_cmd_output);
|
||||
}
|
||||
close($find_cmd_output);
|
||||
|
||||
return $sources;
|
||||
}
|
||||
|
||||
my $header = <<__EOD;
|
||||
Proxmox message catalog.
|
||||
@ -125,6 +128,8 @@ sub extract_msg {
|
||||
if !$count;
|
||||
}
|
||||
|
||||
my $sources = find_js_sources($dirs);
|
||||
|
||||
foreach my $s (@$sources) {
|
||||
open(my $SRC_FH, '<', $s) || die "unable to open file '$s' - $!\n";
|
||||
while(defined(my $line = <$SRC_FH>)) {
|
||||
|
Loading…
Reference in New Issue
Block a user