[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Fixing missing i18n links



Why can't I just attach files when I promise to attach them?  This
sucks.  Please ignore the last mail, this one has a description *and*
an attachement.

Martin Schulze wrote:
> Hi,
> 
> attached please find a script that could help us correct the web pages
> that fail to contain a link to all localized copies of it.
> I.e. foo.en.html is there, not listing foo.sv.html, but the latter
> file was created recently, listing the english copy.  Now foo.es.html
> gets added as well, it will contain links to the english and swedish
> pages.  The other files won't get updated.
> 
> This script does the following:
> 
>   1. Keep two lists of all .wml files around, one current and one from
>      the last run.
> 
>   2. Make a diff and continue to work with these files that were
>      added.
> 
>   3. For those files output the command to touch all relevant files.
>      When the output is eval ``'ed, wml should rebuild the other .html
>      files as well, so cn-links on the web pages will be in sync
>      again.
> 
> The program has to be adjusted wrt. the directory where .wml files are
> and where data files should be stored.
> 
> Joy, could you review this and tell me if you want to add it to the
> website creation?  Do you want me something to improve?  Do you want
> it to call system "touch ..." on its own instead of producing output?
> (I've decided to let it output stuff and not do anything else for demo
> issues.) 
> 
> Others, could you review it as well please?
> 
> Regards,
> 
> 	Joey
> 
> -- 
> Those who don't understand Unix are condemned to reinvent it, poorly.
> 
> Please always Cc to me when replying to me on the lists.

-- 
Those who don't understand Unix are condemned to reinvent it, poorly.

Please always Cc to me when replying to me on the lists.
#! /usr/bin/perl

%config = ('wmldir'  => '/home/project/Debian/CVS/webwml',
	   'datadir' => '/home/project/Debian/CVS/webwml',
	   );

sub make_listing
{
    unlink ("$config{'datadir'}/wmlfiles.old") if (-f "$config{'datadir'}/wmlfiles.old");
    rename ("$config{'datadir'}/wmlfiles", "$config{'datadir'}/wmlfiles.old") if (-f "$config{'datadir'}/wmlfiles");
    system ("find . -type f -name '*.wml' | sort > $config{'datadir'}/wmlfiles");
}

sub obtain_files
{
    my @list;
    return if (! -f "$config{'datadir'}/wmlfiles.old" || ! -f "$config{'datadir'}/wmlfiles");
    if (open (IN, "diff -0 $config{'datadir'}/wmlfiles.old $config{'datadir'}/wmlfiles|")) {
	while (<IN>) {
	    next until (/^> \.\//);
	    s/^> \.\///;
	    chomp ();
	    push (@list, $_);
	}
	close (IN);
    }
    return @list;
}

chdir ($config{'wmldir'});

make_listing ();

@new_files = obtain_files ();

foreach $file (@new_files) {
    @components = split (/\//, $file);
    shift @components;
    # printf "%s\t%s\n", $file, join ("/", @components);
    printf "touch */%s;\n", join ("/", @components);
}

Reply to: