git.schokokeks.org
Repositories
Help
Report an Issue
tor-webwml.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
ddd4b5dd3
Branches
Tags
bridges
docs-debian
jobs
master
press-clips
tor-webwml.git
include
functions.wmi
Move website to wml
Peter Palfrader
commited
ddd4b5dd3
at 2005-10-04 21:10:34
functions.wmi
Blame
History
Raw
#!/usr/bin/wml <: sub getMetadata($) { my ($file) = @_; open(F, "$file") or die ("Cannot open $file: $!\n"); my $found_metadata = 0; while (<F>) { chomp; if ($_ eq '## translation metadata') { $found_metadata = 1; last; }; }; die ("Did not find translation metadata in $file") unless $found_metadata; my %data; while (<F>) { chomp; if (/^#\s*(\S*):\s*(.*?)\s*$/) { $data{$1} = $2; } else { last; }; }; return %data; }; sub translation_get_masterrevision() { my $page = $WML_SRC_FILENAME; %master = getMetadata("en/$WML_SRC_FILENAME"); die ("Cannot find 'Revision' header in master's translation metadata of en/$WML_SRC_FILENAME") unless exists $master{'Revision'}; my ($rev) = $master{'Revision'} =~ m/([0-9.]+)/; if ($rev eq '') { $rev = '(Revision not a valid number)'; }; return $rev; }; sub translation_get_basedonrevision() { my $page = $WML_SRC_FILENAME; %translation = getMetadata("$(LANG)/$WML_SRC_FILENAME"); die ("Cannot find 'Based-On-Revision' header in translations's translation metadata of $(LANG)/$WML_SRC_FILENAME") unless exists $translation{'Based-On-Revision'}; my ($rev) = $translation{'Based-On-Revision'}; if ($rev eq '') { $rev = '(unknown)'; }; return $rev }; sub translation_current() { return (translation_get_masterrevision() eq translation_get_basedonrevision()); }; :>