make_all.pl 1.37 KB
Newer Older
James A. Treacy's avatar
James A. Treacy committed
1 2
#!/usr/bin/perl -w

3
# Usage: make_all.pl <file1> <file2>...
4

5 6
# 	This will update every version of <file?>, each of which should be
#	the path to a .wml file (without the language directory).
7

8 9
# Note: this script was previously known as new_translation.pl.
# That functionality is replaced by touch_old_files.pl.
10

James A. Treacy's avatar
James A. Treacy committed
11 12 13
require 5.001;
use strict;

14 15 16 17 18 19
# This module resides under webwml/Perl
use lib ($0 =~ m|(.*)/|, $1 or ".") ."/Perl";
use Webwml::Langs;

my $l = Webwml::Langs->new();
my %langs = $l->name_iso();
20
my @languages = $l->names();
21

James A. Treacy's avatar
James A. Treacy committed
22
if (!@ARGV) {
23 24 25 26 27 28 29 30 31
  open SELF, "<$0" or die "Unable to display help: $!\n";
  HELP: while (<SELF>)
  {
    last HELP if (/^require/);
    s/^# ?//;
    next if /^!/;
    print;
  }
  exit;
James A. Treacy's avatar
James A. Treacy committed
32 33
}

34
foreach my $file (@ARGV) {
35
  $file =~ s,^english/,,;
36
  my $path = ""; my $filename = $file;
37
  if ($file =~ m,(.*)/([^/]+)$,) { $path = $1; $filename = $2; };
38
  foreach my $lang (@languages) {
James A. Treacy's avatar
James A. Treacy committed
39
      if ( -f "$lang/$file" ) {
40
         my $pid = fork;
James A. Treacy's avatar
James A. Treacy committed
41 42 43 44
         if ($pid) { # parent
            # do nothing
         }
         else {      # child
45
            print "Making the " . ucfirst $lang . " copy:\n";
46
            system("make -C $lang/$path -W $filename install SUBS="); # no need to handle make's errors
James A. Treacy's avatar
James A. Treacy committed
47 48 49 50 51
            exit 0;
         }
         waitpid($pid,0);
      }
      else {
52
         print "The file isn't translated into " . ucfirst $lang . ".\n";
James A. Treacy's avatar
James A. Treacy committed
53
      }
54
  }
James A. Treacy's avatar
James A. Treacy committed
55
}