source: tags/2.1.5/bin/extract_gettext.pl

Last change on this file was 34, checked in by scdev, 18 years ago

added file extract_gettext.pl

  • Property svn:executable set to *
File size: 735 bytes
Line 
1#!/usr/bin/perl
2#
3# Perl script to extract strings from all the files and print to stdout for use with xgettext.
4
5use FileHandle;
6use File::Basename;
7use File::Find;
8use Cwd;
9
10use strict;
11use vars qw($exts %strings);
12
13if (!@ARGV) {
14    die "No directory paths specified";
15}
16
17$exts = '(\.php$|\.ihtml$)';
18
19foreach (@ARGV) {
20    my $fulldir = cwd() . '/' . $_;
21    find(\&extract, $fulldir);
22}
23print join("\n", sort keys %strings), "\n";
24
25sub 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.