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

document matrix generation in releases/slink/



In www.debian.org/releases/slink/ you will now see a nice document
matrix.  This lists all the translations and formats for the various
versions of the Install Manual.

The tables are dynamically generated by a little Perl procedure:

  &permute_as_matrix('install', 'english', 'croatian',  'czech',  ..)

In order to implement this properly, I used wml::debian::languages.
However, I had to add the following languages:

  $langs{'russian'} = 'ru';
  $langs{'czech'} = 'cz';

As well, I use $trans{$CUR_ISO_LANG}{$lang}, although, again
I had to workaround in some cases where this array didn't have 
entries I needed:

		my $workaroundlang = $trans{$CUR_ISO_LANG}{$lang};
		( $workaroundlang = $lang ) =~ s/^(.)/\U$1/
		    unless $workaroundlang;

I don't know if it's kosher for me to modify languages.wml instead of
working around this way.

I include below the permute_as_matrix() procedure.  It is Install
Manual centric since it presupposes hashes %formats and %arches
defined.  However, I could possibly generalize this.  It might be
valuable as more and more non-WML stuff (i.e., SGML stuff) is
translated (i.e., developers-reference etc).

--
.....Adam Di Carlo....adam@onShore.com.....<URL:http://www.onShore.com/>
#
# emits an HTML table matrix:
#   | arch | format | lang1, lang2, lang3 |
#
sub permute_as_matrix {
    my($file, @langs) = @_;
    my($ext, $arch, $lang);
    my $altcolor = 'white';
    my $ctr = 0;

    foreach $arch (keys %arches) {
	$ctr++;
	my $first = 1;

	foreach $ext (keys %formats) {
	    # alternate the row color
	    if ( $ctr % 2 ) {
		print "\n<tr>\n";
	    } else {
		print "\n<tr bgcolor=\"$altcolor\">\n";
	    }
	    # only print the arch name on the first row
	    if ( $first == 1 ) {
		print "  <td align=\"left\"><a href=\"$arch/$file\">" . $arches{$arch} . "</a></td>\n";
		$first = 0;
	    } else {
		print "  <td>&nbsp;</td>\n";
	    }
	    print "  <td align=\"left\">" . $formats{$ext} . "</td>\n";
	    # permute over languages
	    print "  <td>";
	    foreach $lang (@langs) {
		print "<a href=\"./$arch/$file." . $langs{$lang} . ".$ext\">";
		# sometimes the language name isn't properly defined yet
		my $workaroundlang = $trans{$CUR_ISO_LANG}{$lang};
		( $workaroundlang = $lang ) =~ s/^(.)/\U$1/
		    unless $workaroundlang;
		print $workaroundlang . "</a> \n";
	    }
	    print "  </td>";
	    print "</tr>\n";
	    
	}
    }
}


Reply to: