<!doctype html>
<?php
	

	// parse the locale.yaml file and get the variables
	
	include "Spyc.php";
	$localeYaml = Spyc::YAMLLoad('locale.yaml');

	$lang=$_GET['lang'];

	// optional code for reading the accept language header
	
	/*
	$acceptlang='de-DE';
	// get the accept-language header 
	foreach (getallheaders() as $name => $value) {
  		if ($name == 'Accept-Language'){
			// echo "$name $value";
			$acceptlang = $value;
		}
	}
	echo "$acceptlang";
	
	print "oi $lang oi";	
	*/

	if ( in_array ($lang, array('en-US'))){

		$loc1 = "$lang".".utf8";
		$loc = $lang;
	}
	else
		$loc = "de-DE";

	//$loc = "en-US";
	//print "$loc $loc1";
	$domain = "messages";

	setlocale(LC_MESSAGES, $loc); 
	setlocale(LC_ALL, $loc); 

	$results = putenv("LC_ALL=$loc");
	$results = putenv("LC_MESSAGES=$loc");
	//$results = bindtextdomain($domain,"./locale");



?>
<html >
<head>
	<title><?php echo $localeYaml['title'][$loc]?></title>
	<meta charset="utf-8">
	
	<meta name="viewport" content="width=device-width, initial-scale=1">

	<!-- Kube CSS -->
	<link rel="stylesheet" href="css/kube.min.css">
	<link rel="stylesheet" href="addons/kube-addons.min.css" />

	<link rel="stylesheet" href="master.css" />

</head>
<body>
	<div class="page is-container">
		<div class="main-sidebar text-centered">
			<div id="container">
			
			<img  class="wmdelogo" alt="wikimedia logo" src="Wikimedia_Deutschland-Logo.svg"/>
			<center>
			<a class="languageSelect" href="?lang=de-DE"><?php echo $localeYaml['languageSelectDe'][$loc]?></a><br>
			<a class="languageSelect" href="?lang=en-US"><?php echo $localeYaml['languageSelectEn'][$loc]?></a>
			</center>
			</div>
		</div>      
		<div class="main-content">
			<div class="is-row" style="border:0px solid blue">
				<div class="is-col is-70">
					<?php include "form.php" ?>
				</div>
				<div class="is-col is-30">
					<?php 
#						$ct = @file_get_contents( "./locale/$loc/h1.php"); 
#						if ($ct==false)
#							$ct = file_get_contents( "h1.php"); 
#						echo $ct;

					?>

					<?php 
						$ct = @file_get_contents( "./locale/$loc/h2.php"); 
						if ($ct==false)
							$ct = file_get_contents( "h2.php"); 
						echo $ct;

					?>

				</div>
			</div>
        <?php echo $localeYaml['impressum'][$loc]?>: <a href="https://www.wikimedia.de/impressum/">https://www.wikimedia.de/impressum</a><br>
        <?php echo $localeYaml['privacy'][$loc]?>: <a href="<?php echo $localeYaml['privacyLink'][$loc]?>"><?php echo $localeYaml['privacyLink'][$loc]?></a>
		</div>
	</div>    


	<script src="js/kube.min.js"></script>
	<script src="kaform.js"></script>
	<script src="addons/upload/kube.upload.min.js"></script>
	<script src="addons/kube-addons.min.js"></script>
	<script src="iban.js/iban.js"></script>


	<script>
	error_alert_projectid = "<?php echo $localeYaml['error_alert_projectid'][$loc]?>";
        error_alert_realname = "<?php echo $localeYaml['error_alert_realname'][$loc]?>";
	error_alert_email = "<?php echo $localeYaml['error_alert_email'][$loc]?>";
	error_alert_iban = "<?php echo $localeYaml['error_alert_iban'][$loc]?>";
	error_alert_bic = "<?php echo $localeYaml['error_alert_bic'][$loc]?>";
	error_alert_paypal = "<?php echo $localeYaml['error_alert_paypal'][$loc]?>";
	error_alert_expenses = "<?php echo $localeYaml['error_alert_expenses'][$loc]?>";
	error_alert_agreement = "<?php echo $localeYaml['error_alert_agreement'][$loc]?>";
	error_alert_ismailable = "<?php echo $localeYaml['error_alert_ismailable'][$loc]?>";
	error_alert_date = "<?php echo $localeYaml['error_alert_date'][$loc]?>";
	error_alert_description = "<?php echo $localeYaml['error_alert_description'][$loc]?>";
	error_alert_sum = "<?php echo $localeYaml['error_alert_sum'][$loc]?>";
	expenses_table_description_placeholder = "<?php echo $localeYaml['expenses_table_description_placeholder'][$loc]?>";
	expenses_table_file_placeholder = "<?php echo $localeYaml['expenses_table_file_placeholder'][$loc]?>";

	</script>


 </body>
</html>
