-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxml2pot
More file actions
executable file
·28 lines (21 loc) · 734 Bytes
/
Copy pathxml2pot
File metadata and controls
executable file
·28 lines (21 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/perl
my $regex = '<string name="(.*)">(.*)<\/string>';
my $replace_backslash = s/\\//g;
my $num_args = $#ARGV + 1;
if($num_args != 2) {
print "Missing argument: you must specify the file to convert and the output file!\n\n";
exit;
}
my $filename = $ARGV[0];
my $output = $ARGV[1];
open my $xml, '<', $filename or die "Can't open file $filename";
open my $pot, '>', $output or die "Can't write to file $output";
my @lines = <$xml>;
close $xml or die "Problem while closing file $xml";
foreach my $line (@lines) {
$line =~ s/\\//g;#$replace_backslash;
if($line =~ $regex) {
print $pot "\nmsgctxt \"$1\"\nmsgid \"$2\"\nmsgstr \"\"\n";
}
}
close $pot or die "Problem closing file $pot";