#!/usr/bin/perl # # Perl script to extract strings from all the files and print to stdout for use with xgettext. use FileHandle; use File::Basename; use File::Find; use Cwd; use strict; use vars qw($exts %strings); if (!@ARGV) { die "No directory paths specified"; } $exts = '(\.php$|\.ihtml$)'; foreach (@ARGV) { my $fulldir = cwd() . '/' . $_; find(\&extract, $fulldir); } print join("\n", sort keys %strings), "\n"; sub extract { my $file = $File::Find::name; my $fd = new FileHandle; if ($file =~ /$exts/) { open($fd, basename($file)); my $data = join('', <$fd>); while ($data =~ s/_\("(.*?)"\)//s) { $strings{"_(\"$1\")"}++; } close($fd); } }