aboutsummaryrefslogtreecommitdiffstats
path: root/copypage.pl
diff options
context:
space:
mode:
authorPeter Karlsson <peterk>2000-10-03 23:03:44 +0000
committerPeter Karlsson <peterk>2000-10-03 23:03:44 +0000
commit54a19cccb174aa4e7da0e4cb69da118a4b7e5440 (patch)
tree310db6abf2078e1328acde4f6b4858a5ea466bdb /copypage.pl
parent033b27678d30fb815e5324a922e810bb06adbe14 (diff)
Updated to use the translation-check template
CVS version numbers copypage.pl: 1.4 -> 1.5 swedish/News/weekly/copyissue.pl: 1.5 -> 1.6 swedish/security/copyadvisory.pl: 1.2 -> 1.3
Diffstat (limited to 'copypage.pl')
-rwxr-xr-xcopypage.pl173
1 files changed, 94 insertions, 79 deletions
diff --git a/copypage.pl b/copypage.pl
index eae864cebb7..b04ca993c7c 100755
--- a/copypage.pl
+++ b/copypage.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
# This script copies the file named on the command line to the translation
-# named in copypage.conf, and adds the <!--translation x.x--> string to it.
+# named in copypage.conf, and adds the translation-check header to it.
# It also will create the destination directory if necessary, and copy the
# Makefile from the source.
@@ -11,9 +11,19 @@
# $Id$
-# Get command line and configuration
-$page = $ARGV[0];
+# Check usage.
+if ($#ARGV == -1)
+{
+ print "Usage: $0 page ...\n\n";
+ print "Copies the page from the english/ directory to the $language/ directory\n";
+ print "and adds the translation-check header\n";
+ print "If the directory does not exist, it will be created, and the Makefile\n";
+ print "copied.\n\n";
+ print "You can either keep or not keep the 'english/' part of the path.\n";
+ exit;
+}
+# Get configuration
if (open CONF, "<language.conf")
{
$language = <CONF>;
@@ -25,106 +35,111 @@ else
$language = 'swedish';
}
-# Check usage.
-unless ($page)
+# Loop over commnad line
+foreach $page (@ARGV)
{
- print "Usage: $0 page\n\n";
- print "Copies the page from the english/ directory to the $language/ directory\n";
- print "and adds the translation string\n";
- print "If the directory does not exist, it will be created, and the Makefile\n";
- print "copied.\n\n";
- print "You can either keep or not keep the 'english/' part of the path.\n";
- exit;
+ # Check if valid source
+ if ($page =~ /wml$/)
+ {
+ &copy($page);
+ }
+ else
+ {
+ print "$page does not seem to be a valid page.\n";
+ }
}
-# Check if valid source
-unless ($page =~ /wml$/)
-{
- print "$page does not seem to be a valid page.\n";
- exit;
-}
-# Remove english/ from path
-if ($page =~ m[^english/])
+# Subroutine to copy a page
+sub copy
{
- $page =~ s[^english/][];
-}
+ my $page = shift;
+ print "Processing $page...\n";
-# Create needed file and directory names
-$srcfile = "english/$page"; # Source file path
-$dstfile = "$language/$page"; # Destination file path
+ # Remove english/ from path
+ if ($page =~ m[^english/])
+ {
+ $page =~ s[^english/][];
+ }
-$srcdir = $srcfile;
-$srcdir =~ s[(.*/).*][$1]; # Source directory (trailing /)
-$dstdir = $dstfile;
-$dstdir =~ s[(.*/).*][$1]; # Desination directory (trailing /)
+ # Create needed file and directory names
+ my $srcfile = "english/$page"; # Source file path
+ $dstfile = "$language/$page"; # Destination file path
-$filename = $srcfile;
-$filename =~ s[$srcdir][]; # Pathless filename
+ my $srcdir = $srcfile;
+ $srcdir =~ s[(.*/).*][$1]; # Source directory (trailing /)
+ my $dstdir = $dstfile;
+ $dstdir =~ s[(.*/).*][$1]; # Desination directory (trailing /)
-$cvsfile = "$srcdir/CVS/Entries"; # Name of file with CVS revisions
+ my $filename = $srcfile;
+ $filename =~ s[$srcdir][]; # Pathless filename
-$srcmake = $srcdir . "Makefile"; # Name of source Makefile
-$dstmake = $dstdir . "Makefile"; # Name of destination Makefile
+ my $cvsfile = "$srcdir/CVS/Entries";# Name of file with CVS revisions
-# Sanity checks
-die "Directory $srcdir does not exist\n" unless -d $srcdir;
-die "File $srcfile does not exist\n" unless -e $srcfile;
-die "File $dstfile already exists\n" if -e $dstfile;
+ my $srcmake = $srcdir . "Makefile"; # Name of source Makefile
+ my $dstmake = $dstdir . "Makefile"; # Name of destination Makefile
-# Check if destination exists, if not - create it
-unless (-d $dstdir)
-{
- print "Destination directory $dstdir does not exist,\n";
- print "creating and copying $dstmake\n";
+ # Sanity checks
+ die "Directory $srcdir does not exist\n" unless -d $srcdir;
+ die "File $srcfile does not exist\n" unless -e $srcfile;
+ die "File $dstfile already exists\n" if -e $dstfile;
- mkdir $dstdir, 0755
- or die "Could not create $dstdir: $!\n";
- system "cp $srcmake $dstmake";
-}
+ # Check if destination exists, if not - create it
+ unless (-d $dstdir)
+ {
+ print "Destination directory $dstdir does not exist,\n";
+ print "creating and copying $dstmake\n";
-# Open the files
-open CVS, $cvsfile
- or die "Could not read $cvsfile ($!)\n";
+ mkdir $dstdir, 0755
+ or die "Could not create $dstdir: $!\n";
+ system "cp $srcmake $dstmake";
+ }
-open SRC, $srcfile
- or die "Could not read $srcfile ($!)\n";
+ # Open the files
+ open CVS, $cvsfile
+ or die "Could not read $cvsfile ($!)\n";
-open DST, ">$dstfile"
- or die "Could not create $dstfile ($!)\n";
+ open SRC, $srcfile
+ or die "Could not read $srcfile ($!)\n";
-# Retrieve CVS revision number
-while (<CVS>)
-{
- if (m[^/$filename/([0-9]*\.[0-9]*)/]o)
+ open DST, ">$dstfile"
+ or die "Could not create $dstfile ($!)\n";
+
+ # Retrieve CVS revision number
+ my $revision;
+ while (<CVS>)
{
- $revision = $1;
+ if (m[^/$filename/([0-9]*\.[0-9]*)/]o)
+ {
+ $revision = $1;
+ }
}
-}
-close CVS;
+ close CVS;
-unless ($revision)
-{
- print "Could not get revision number - bug in script?\n";
- $revision = '1.1';
-}
+ unless ($revision)
+ {
+ print "Could not get revision number - bug in script?\n";
+ $revision = '1.1';
+ }
-# Copy the file and insert the revision number
-$insertedrevision = 0;
+ # Copy the file and insert the revision number
+ my $insertedrevision = 0;
-while (<SRC>)
-{
- unless ($insertedrevision || /^#/)
+ while (<SRC>)
{
- print DST "# <!--translation $revision-->\n";
- $insertedrevision = 1;
+ unless ($insertedrevision || /^#/)
+ {
+ print DST qq'#use wml::debian::translation-check translation="$revision"\n';
+ $insertedrevision = 1;
+ }
+ print DST $_;
}
- print DST $_;
-}
-close SRC;
-close DST;
+ close SRC;
+ close DST;
+
+ # We're done
+ print "Copied $page, remember to edit $dstfile\n";
+}
-# We're done
-print "Copying done, remember to edit $dstfile\n";

© 2014-2024 Faster IT GmbH | imprint | privacy policy