#use wml::std::tags #use wml::debian::languages # given a manual name and an architecture, join them # if you need to reorder the two, use "%2$s ... %1$s", cf. printf(3) %s for %s # ## the non-generic name of the document that contains the installation manual # Installation Guide # # ## the non-generic name of the document that contains the release notes # Release Notes # # # emits a bunch of li (list items) # assumes %arches, @arches and $indirect_object_conjoiner # sub permute_as_list { my($file, $name, @noarches) = @_; my($print, $arch, $noarch); # if ($name eq 'Release Notes') { # $name = q{}; # elsif ($name eq 'Installation Guide') { # $name = q{}; # } @arches || die "@arches is not set\n"; foreach $arch (@arches) { $print = 1; if ( $#noarches != -1 ) { foreach $noarch (@noarches) { $print = 0 if ( $arch eq $noarch ); } } if ( $print == 1 ) { print "
  • "; printf q{}, $name, $arches{$arch}; print ""; print "\n"; } } } # # emits an HTML table matrix: # | arch | format | lang1, lang2, lang3 | # assumes %arches, @arches and %formats # sub permute_as_matrix { my($file, @langs) = @_; my($ext, $arch, $lang, $l10nlang, @cur_dir, $release); # my $altcolor = 'white'; my $ctr = 0; my $check_if_file_exists = 0; @cur_dir = split('/', '$(WML_SRC_DIRNAME)'); $release = pop @cur_dir; @arches || die "@arches is not set\n"; %formats || die "%formats is not set\n"; if ($file =~ /release-notes/) { # these two releases had installmanual.*.pdf but no release-notes.*.pdf if ($release eq 'slink' or $release eq 'potato') { delete $formats{'pdf'}; }; }; my %sorted_langs = (); foreach (@langs) { $sorted_langs{$trans{$(CUR_ISO_LANG)}{$_}} = $_; } foreach $arch (@arches) { $ctr++; my $first = 1; foreach $ext (keys %formats) { if ($check_if_file_exists && ! -f "$(HTMLDIR)/releases/$release/$arch/$file.en.$ext") { next; } # alternate the row color if ( $ctr % 2 ) { print "\n\n"; } else { print "\n\n"; } # only print the arch name on the first row if ( $first == 1 ) { if ($file =~ /release-notes/) { print " " . $arches{$arch} . "\n"; } else { print " " . $arches{$arch} . "\n"; } $first = 0; } else { print "  \n"; } print " " . $formats{$ext} . "\n"; # permute over languages print " "; foreach $l10nlang (sort langcmp keys %sorted_langs) { $lang = $sorted_langs{$l10nlang}; next if ($ext eq "pdf" && $lang eq "japanese"); next if ($ext eq "pdf" && $lang eq "russian"); $file_version = "$arch/$file." . $langsinstall{$lang} . ".$ext"; if ( $file =~ /release-notes/ && $ext eq "html" ) { # convert languages with sublangs (zh_TW -> zh-tw) (my $html_lang = $langsrelnotes{$lang}) =~ s/(\w\w)_(\w\w)/"$1-".lc($2)/e; $file_version = "$arch/$file/index." . $html_lang . ".$ext"; } elsif ( $file =~ /release-notes/ && (($ext eq "txt") || ($ext eq "pdf"))) { $file_version = "$arch/$file." . $langsrelnotes{$lang} . ".$ext"; } if (! $check_if_file_exists || -f "$(HTMLDIR)/releases/$release/$file_version") { # all languages should be defined in %trans. Add missing entries # in English if this is not the case print "" if $lang eq lc($CUR_LANG); print "" . $trans{$CUR_ISO_LANG}{$lang} . ""; print "" if $lang eq lc($CUR_LANG); print " \n"; } } print " "; print "\n"; } } } sub permute_as_matrix_new { my %options = @_; my $file = $options{file} or die "permute_as_matrix: file argument is required"; my $html_file = $options{html_file} || $file; my %langs = %{$options{langs}} or die "permute_as_matrix: langs argument is required"; my @arches = @{$options{arches}} or die "permute_as_matrix: arches argument is required"; my %formats = %{$options{formats}} or die "permute_as_matrix: formats argument is required"; my %missing = map { $_ => 1 } @{$options{missing}}; # my $altcolor = $options{altcolor} || 'white'; my $namingscheme = $options{namingscheme} || sub { join('.',@_); }; # name, lang, ext my $dirmode = $options{dirmode}; my $check_if_file_exists = exists $options{checkfiles} ? $options{checkfiles} : 1; my ($ext, $arch, $lang, $l10nlang, @cur_dir, $release); @cur_dir = split('/', '$(WML_SRC_DIRNAME)'); $release = pop @cur_dir; my $ctr = 0; my $targetdir = "$(HTMLDIR)/releases/$release"; my %sorted_langs = (); foreach (keys %langs) { $sorted_langs{$trans{$(CUR_ISO_LANG)}{$_}} = $_; } foreach $arch (@arches) { $ctr++; my $first = 1; foreach $ext (sort keys %formats) { my $targetfile = "$arch/".(($ext eq 'html') ? $html_file : $file); if ($check_if_file_exists && ! -f &$namingscheme( "$targetdir/$targetfile", 'en', $ext ) ) { next; } # alternate the row color if ( $ctr % 2 ) { print "\n\n"; } else { print "\n\n"; } # only print the arch name on the first row if ( $first == 1 ) { print " " . $arches{$arch} . "\n"; $first = 0; } else { print "  \n"; } print " " . $formats{$ext} . "\n"; # permute over languages print " "; foreach $l10nlang (sort langcmp keys %sorted_langs) { $lang = $sorted_langs{$l10nlang}; next if exists $missing{"$lang:$ext"}; $file_version = &$namingscheme( $targetfile, $langs{$lang}, $ext ); # convert languages with sublangs (zh_TW -> zh-tw) (my $lang_alt = $langs{$lang}) =~ s/(\w\w)_(\w\w)/"$1-".lc($2)/e; my $file_version_alt = &$namingscheme( $targetfile, $lang_alt, $ext ); if( $check_if_file_exists && ! -f "$targetdir/$file_version" && -f "$targetdir/$file_version_alt" ) { $file_version = $file_version_alt; } if (! $check_if_file_exists || -f "$targetdir/$file_version") { # all languages should be defined in %trans. Add missing entries # in English if this is not the case print "" if $lang eq lc($CUR_LANG); print "" . $trans{$CUR_ISO_LANG}{$lang} . ""; print "" if $lang eq lc($CUR_LANG); print " \n"; } } print " "; print "\n"; } } }