[or-cvs] Make translation status more verbose
Peter Palfrader
weasel at seul.org
Sat Oct 8 12:16:47 UTC 2005
Update of /home/or/cvsroot/website/include
In directory moria:/tmp/cvs-serv27442/include
Modified Files:
functions.wmi head.wmi links.wmi perl-globals.wmi
Log Message:
Make translation status more verbose
use 'use strict' in perl stuff.
Index: functions.wmi
===================================================================
RCS file: /home/or/cvsroot/website/include/functions.wmi,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- functions.wmi 5 Oct 2005 02:13:04 -0000 1.5
+++ functions.wmi 8 Oct 2005 12:16:45 -0000 1.6
@@ -5,6 +5,8 @@
sub getMetadata($) {
my ($file) = @_;
+ die ("File $file is not a regular file") unless (-f $file);
+
open(F, "$file") or die ("Cannot open $file: $!\n");
my $found_metadata = 0;
while (<F>) {
@@ -24,16 +26,16 @@
last;
};
};
- return %data;
+ return \%data;
};
sub translation_get_masterrevision_file($) {
my ($page) = @_;
- %master = getMetadata("en/$page");
+ my $master = getMetadata("en/$page");
- die ("Cannot find 'Revision' header in master's translation metadata of en/$page") unless exists $master{'Revision'};
+ die ("Cannot find 'Revision' header in master's translation metadata of en/$page") unless exists $master->{'Revision'};
- my ($rev) = $master{'Revision'} =~ m/([0-9.]+)/;
+ my ($rev) = $master->{'Revision'} =~ m/([0-9.]+)/;
if ($rev eq '') { $rev = '(Revision not a valid number)'; };
return $rev;
@@ -44,17 +46,17 @@
sub translation_get_basedonrevision_langfile($$) {
my ($lang, $page) = @_;
- %translation = getMetadata("$lang/$page");
+ my $translation = getMetadata("$lang/$page");
- die ("Cannot find 'Based-On-Revision' header in translations's translation metadata of $lang/$page") unless exists $translation{'Based-On-Revision'};
+ die ("Cannot find 'Based-On-Revision' header in translations's translation metadata of $lang/$page") unless exists $translation->{'Based-On-Revision'};
- my ($rev) = $translation{'Based-On-Revision'};
+ my ($rev) = $translation->{'Based-On-Revision'};
if ($rev eq '') { $rev = '(unknown)'; };
return $rev
};
sub translation_get_basedonrevision() {
- translation_get_basedonrevision_langfile($(LANG), $WML_SRC_FILENAME);
+ translation_get_basedonrevision_langfile("$(LANG)", $WML_SRC_FILENAME);
};
@@ -64,8 +66,8 @@
sub file_is_obsolete($$) {
my ($lang, $page) = @_;
- %translation = getMetadata("$lang/$page");
- return (exists $translation{'Status'} && ($translation{'Status'} eq 'obsolete'))
+ my $translation = getMetadata("$lang/$page");
+ return (exists $translation->{'Status'} && ($translation->{'Status'} eq 'obsolete'))
};
:>
Index: head.wmi
===================================================================
RCS file: /home/or/cvsroot/website/include/head.wmi,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- head.wmi 7 Oct 2005 22:43:08 -0000 1.4
+++ head.wmi 8 Oct 2005 12:16:45 -0000 1.5
@@ -1,4 +1,5 @@
#! /usr/bin/wml
+<: use strict; :>
#include "perl-globals.wmi"
#include "links.wmi"
#include "versions.wmi"
@@ -23,15 +24,17 @@
<td class="banner-left"></td>
<td class="banner-middle">
<:
+ my %navigation;
+ my @keys;
while (@navigation) {
- $key = shift @navigation;
- $val = shift @navigation;
+ my $key = shift @navigation;
+ my $val = shift @navigation;
push @keys, $key;
$navigation{$key} = $val;
}
- for $key (@keys) {
- $page = $WML_SRC_FILENAME;
+ for my $key (@keys) {
+ my $page = $WML_SRC_FILENAME;
$page =~ s/\.wml//;
if ($page ne $key) {
printf '<a href="%s.html.$(LANG)">%s</a>'."\n", $key, $navigation{$key};
@@ -43,7 +46,7 @@
</td>
<td class="banner-right">
<:
- $page = $WML_SRC_FILENAME;
+ my $page = $WML_SRC_FILENAME;
$page =~ s/\.wml//;
for my $dir (sort {$LANGUAGES{$a} cmp $LANGUAGES{$b}} @LANGUAGES) {
next if $dir eq '$(LANG)';
Index: links.wmi
===================================================================
RCS file: /home/or/cvsroot/website/include/links.wmi,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- links.wmi 7 Oct 2005 22:43:08 -0000 1.3
+++ links.wmi 8 Oct 2005 12:16:45 -0000 1.4
@@ -6,8 +6,8 @@
# Xinclude "langlocallinks.$(LANG).wmi"
<define-tag page whitespace=delete><:
- $page="%0";
- $lang="$(LANG)";
+ my $page="%0";
+ my $lang="$(LANG)";
if (-e "$lang/$page.wml") {
print "%0.html.$lang";
} elsif (-e "en/$page.wml") {
Index: perl-globals.wmi
===================================================================
RCS file: /home/or/cvsroot/website/include/perl-globals.wmi,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- perl-globals.wmi 5 Oct 2005 15:37:00 -0000 1.1
+++ perl-globals.wmi 8 Oct 2005 12:16:45 -0000 1.2
@@ -6,4 +6,5 @@
'de' => "Deutsch",
'it' => "Italiano"
);
+ our $WML_SRC_FILENAME;
:>
More information about the tor-commits
mailing list