[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Add sanity check for defined languages



Update of /home/or/cvsroot/website/include
In directory moria:/tmp/cvs-serv15469

Modified Files:
	perl-globals.wmi 
Log Message:
Add sanity check for defined languages

Index: perl-globals.wmi
===================================================================
RCS file: /home/or/cvsroot/website/include/perl-globals.wmi,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -p -d -r1.4 -r1.5
--- perl-globals.wmi	21 Dec 2005 00:36:13 -0000	1.4
+++ perl-globals.wmi	21 Dec 2005 00:43:11 -0000	1.5
@@ -1,11 +1,21 @@
 #!wml
 <:
+	# Change both.  The array is ordered (for pages like translation status).
+	# The order of flasg in head is based on sort order of language name.
 	my @LANGUAGES = qw{en de it fr};
 	my %LANGUAGES = (
 		'en' => "English",
 		'de' => "Deutsch",
 		'it' => "Italiano",
-		'fr' => "Fran&ccedil;ais"
+		'fr' => "Fran&ccedil;ais",
 		);
 	our $WML_SRC_FILENAME;
+
+	# sanity check.
+	for my $lang (@LANGUAGES) {
+		die "Language $lang defined in \@LANGUAGES but not in \%LANGUAGES in perl-globals"
+			unless exists $LANGUAGES{$lang};
+	};
+	die "\@LANGUAGES and \%LANGUAGES have a different number of elements in perl-globals"
+		unless (scalar @LANGUAGES == scalar keys %LANGUAGES);
 :>