[go: up one dir, main page]

File: extract.pl

package info (click to toggle)
sork-accounts 2.1.2-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 532 kB
  • ctags: 79
  • sloc: sh: 553; php: 360; makefile: 114; perl: 30; xml: 16
file content (45 lines) | stat: -rw-r--r-- 919 bytes parent folder | download
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/perl
#
# $Horde: accounts/po/extract.pl,v 1.1.1.1 2002/05/22 03:10:15 ericr Exp $
#
# 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 @dirs $dirs %strings);

chdir(dirname($0));

@dirs = qw($ /templates /lib /config /admin /util);

$exts = '(\.php$|\.inc$|\.dist$)';
$dirs = '^' . cwd() . '/..(' . join('|', @dirs) . ')';

find(\&extract, cwd() . '/..');
print join("\n", sort keys %strings), "\n";

sub extract
{
  my $file = $File::Find::name;
  my $dir  = $File::Find::dir;
  my $fd   = new FileHandle;

  if ($dir !~ /$dirs/s) {
    $File::Find::prune = 1;
    return;
  }

  if ($file =~ /$exts/) {
    open($fd, basename($file));
    my $data = join('', <$fd>);
    while ($data =~ s/_\("(.*?)"\)//s) {
      $strings{"_(\"$1\")"}++;
    }
    close($fd);
  }
}