Last active
December 22, 2015 01:59
-
-
Save zaferkorucu/6400662 to your computer and use it in GitHub Desktop.
Çoklu Dil
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Session başlat | |
session_start(); | |
# Dil seçimi yapılmışsa | |
if($_GET['dil']) { | |
# Dil seçimini session'a ata. | |
$_SESSION['dil'] = $_GET['dil']; | |
# Anasayfa'ya yönlendir. | |
header("Location:index.php"); | |
} | |
# Seçili dili kontrol ediyoruz | |
if ($_SESSION['dil'] == "en") { | |
$dil = "en"; | |
} | |
elseif ($_SESSION['dil'] == "tr") { | |
$dil = "tr"; | |
} | |
else { | |
# Eğer dil seçilmemişse tarayıcı dilini varsayılan dil olarak seçiyoruz | |
$dil = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'],0,2); | |
} | |
# Dil dosyamızı include ediyoruz | |
include 'dil/'.$dil.'.php'; | |
?> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | |
<!-- Site Title --> | |
<title><?php echo $diller['title'];?></title> | |
</head> | |
<body> | |
<!-- Dil Seçim --> | |
<a class="dilSec" href="?dil=tr">TR</a> | |
<a class="dilSec" href="?dil=en">EN</a> | |
<!-- Menü Yapısı --> | |
<ul> | |
<li><a href="index.php"><?php echo $diller['anasayfa'];?></a></li> | |
<li><a href="hakkimizda.php"><?php echo $diller['hakkimizda'];?></a></li> | |
<li><a href="iletisim.php"><?php echo $diller['iletisim'];?></a></li> | |
</ul> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment