From aaad09b704adb6467ae8f8463483674320ae4ad0 Mon Sep 17 00:00:00 2001 From: Swedish Language Team Date: Sat, 26 Feb 2000 17:41:28 +0000 Subject: Added script that automates creation of new translations; it will copy the requested page from the English directory to the local translation directory (as specified in language.conf) and add the '' line. If the destination directory does not exist, it will be created and the Makefile copied. It will unfortunately not translate the page for you... :-) CVS version numbers copypage.pl: INITIAL -> 1.1 --- copypage.pl | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100755 copypage.pl (limited to 'copypage.pl') diff --git a/copypage.pl b/copypage.pl new file mode 100755 index 00000000000..db919acbbd8 --- /dev/null +++ b/copypage.pl @@ -0,0 +1,125 @@ +#!/usr/bin/perl -w + +# This script copies the file named on the command line to the translation +# named in copypage.conf, and adds the string to it. +# It also will create the destination directory if necessary, and copy the +# Makefile from the source. + +# Written on 2000-02-26 by peter karlsson +# © Copyright 2000 Software in the public intereset, Inc. +# This program is released under the GNU General Public License, v2. + +# $Id$ + +# Get command line and configuration +$page = $ARGV[0]; + +if (open CONF, "; + chomp $language; + close CONF; +} +else +{ + $language = 'swedish'; +} + +# Check usage. +unless ($page) +{ + print "Usage: $0 page\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"; + print "You can either keep or not keep the 'english/' part of the path.\n"; + exit; +} + +# 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/]) +{ + $page =~ s[^english/][]; +} + +# Create needed file and directory names +$srcfile = "english/$page"; # Source file path +$dstfile = "$language/$page"; # Destination file path + +$srcdir = $srcfile; +$srcdir =~ s[(.*/).*][$1]; # Source directory (trailing /) +$dstdir = $dstfile; +$dstdir =~ s[(.*/).*][$1]; # Desination directory (trailing /) + +$filename = $srcfile; +$filename =~ s[$srcdir][]; # Pathless filename + +$cvsfile = "$srcdir/CVS/Entries"; # Name of file with CVS revisions + +$srcmake = $srcdir . "Makefile"; # Name of source Makefile +$dstmake = $dstdir . "Makefile"; # Name of destination Makefile + +# Sanity checks +die "Directory $srcdir does not exist\n" unless -d $srcdir; +die "File $srcfile does not exist\n" unless -e $srcfile; + +# 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"; + + mkdir $dstdir, 0755 + or die "Could not create $dstdir: $!\n"; + system "cp $srcmake $dstmake"; +} + +# Open the files +open CVS, $cvsfile + or die "Could not read $cvsfile ($!)\n"; + +open SRC, $srcfile + or die "Could not read $srcfile ($!)\n"; + +open DST, ">$dstfile" + or die "Could not create $dstfile ($!)\n"; + +# Retrieve CVS revision number +while () +{ + if (m[^/$filename/([0-9]*\.[0-9])*/]o) + { + $revision = $1; + } +} + +close CVS; + +print "Could not get revision number\n" unless $revision; + +# Copy the file and insert the revision number +$insertedrevision = 0; + +while () +{ + unless ($insertedrevision || /^#/) + { + print DST "# \n"; + $insertedrevision = 1; + } + print DST $_; +} + +close SRC; +close DST; + +# We're done +print "Copying done, remember to edit $dstfile\n"; -- cgit v1.2.3