Last change
on this file since 347 was
34,
checked in by scdev, 19 years ago
|
added file extract_gettext.pl
|
-
Property svn:executable set to
*
|
File size:
735 bytes
|
Rev | Line | |
---|
[34] | 1 | #!/usr/bin/perl |
---|
| 2 | # |
---|
| 3 | # Perl script to extract strings from all the files and print to stdout for use with xgettext. |
---|
| 4 | |
---|
| 5 | use FileHandle; |
---|
| 6 | use File::Basename; |
---|
| 7 | use File::Find; |
---|
| 8 | use Cwd; |
---|
| 9 | |
---|
| 10 | use strict; |
---|
| 11 | use vars qw($exts %strings); |
---|
| 12 | |
---|
| 13 | if (!@ARGV) { |
---|
| 14 | die "No directory paths specified"; |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | $exts = '(\.php$|\.ihtml$)'; |
---|
| 18 | |
---|
| 19 | foreach (@ARGV) { |
---|
| 20 | my $fulldir = cwd() . '/' . $_; |
---|
| 21 | find(\&extract, $fulldir); |
---|
| 22 | } |
---|
| 23 | print join("\n", sort keys %strings), "\n"; |
---|
| 24 | |
---|
| 25 | sub extract |
---|
| 26 | { |
---|
| 27 | my $file = $File::Find::name; |
---|
| 28 | my $fd = new FileHandle; |
---|
| 29 | |
---|
| 30 | if ($file =~ /$exts/) { |
---|
| 31 | open($fd, basename($file)); |
---|
| 32 | my $data = join('', <$fd>); |
---|
| 33 | while ($data =~ s/_\("(.*?)"\)//s) { |
---|
| 34 | $strings{"_(\"$1\")"}++; |
---|
| 35 | } |
---|
| 36 | close($fd); |
---|
| 37 | } |
---|
| 38 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.