#!/usr/bin/perl

# Automatic generation of links for days of the year
# for http://fr.wikipedia.org
# (c) Yann Forget
# Release under GPL, see http://www.gnu.org/

# Not used !
@months=("janvier","f?vrier","mars","avril","mai","juin","juillet","ao?t",
	"septembre","octobre","novembre","d?cembre");
	
$format_months="[[janvier]] | [[f?vrier]] | [[mars]] | [[avril]] | [[mai]]";
$format_months.=" | [[juin]] | [[juillet]] | [[ao?t]] | [[septembre]]";
$format_months.=" | [[octobre]] | [[novembre]] | [[d?cembre]]";

# Not used !
@codes=("en:","de:","pl:","eo:","es:","nl:","sv:","pt:","no:","da:");

@m=(
	# French
	["janvier","f?vrier","mars","avril","mai","juin","juillet","ao?t","septembre","octobre","novembre","d?cembre"],
	# English
	["January","February","March","April","May","June","July","August","September","October","November","December"],
	# German
	["Januar","Februar","M?rz","April","Mai","Juni","Juli","August","September","October","November","Dezember"],
	# Polish
	["stycznia","lutego","marca","kwietnia","maja","czerwca","lipca","sierpnia","wrzesnia","pazdziernika","listopada","grudnia"],
	# Esperanto
	["januaro","februaro","marto","aprilo","majo","junio","julio","augosto","septembro","oktobro","novembro","decembro"],
	# Spanish
	["enero","febrero","marzo","abril","mayo","junio","julio","agosto","septiembre","octubre","noviembre","diciembre"],
	# Dutch
	["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],
	# Swedish
	["januari","februari","mars","april","maj","juni","juli","augusti","september","oktober","november","december"],
	# Norvegian
	["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],
	# Danish
	["Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December"],
	);

#print $m[0][1]," ",${$m[1]}[1]," \n";

my $i=0;
#foreach $month (@months) {
foreach $month (@{$m[0]}) {
	foreach $day (1..31) {
	
		$format_links="[[en:".${$m[1]}[$i]." $day]]";
		$format_links.=" [[de:$day. ".${$m[2]}[$i]."]]";
		$format_links.=" [[pl:$day ".${$m[3]}[$i]."]]";
		$format_links.=" [[eo:$day-a de ".${$m[4]}[$i]."]]";
		$format_links.=" [[es:$day de ".${$m[5]}[$i]."]]";
		$format_links.=" [[nl:$day ".${$m[6]}[$i]."]]";
		$format_links.=" [[sv:$day ".${$m[7]}[$i]."]]";
		$format_links.=" [[no:$day. ".${$m[8]}[$i]."]]";
		$format_links.=" [[da:$day. ".${$m[9]}[$i]."]]";
		$format_links.="\n";
		
		my $d1=$day-1;
		my $d2=$day+1;
		$format_days="* [[$d1 $month]] | [[$d2 $month]]\n";
		print $format_links," ",$format_days,"\n";

		$file="$day-$month.txt";
		&print_file($file);
	}
	$i++;	
}

sub print_file() {
	my $file = shift;

	print $file,"\n";
	open DAY, ">$file" or die "Can't create $file: $!";

	print DAY $format_links;

	print DAY "----\n";
	print DAY "Voir aussi :\n";
	print DAY $format_days;
	print DAY "* $format_months\n";
	print DAY "* Les [[366 jours]] de l'ann?e.\n\n";
			
	close DAY;
}


