Merhabalar

Bir çoğumuz kurumsal siteler kodlarken firma iki üç dilde olmasını istiyor.Bende size faydası olması için bunu php’de define ile nasıl yaparız onu göstereceğiz.

Öncelikle değişik bir çok yol var ben bu yöntemi kullanıyorum değişik yollarda mevcut.

İndex.php adında bir sayfa oluşturuyoruz bu sayfa içine;

1
2
3
4
5
<?php
echo '<center><title>DIL Kontrol</title>';
echo '<a href="kontrol.php?dil=TR">TÜRKÇE</a><a href="kontrol.php?dil=TR"></a> - <a href="kontrol.php?dil=EN">ENGLISH</a></div>'."<br>";
echo '</center>';
?>

kontrol.php adında bir sayfa oluşturuyoruz bu sayfa içine;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php
$dil =$_GET["dil"];
include ("$dil.php");
echo '<table width="200" border="1">
<tr>
<th scope="col">'.Ana.'</th>
<th scope="col">'.Dersler.'</th>
<th scope="col">'.Moduller.'</th>
<th scope="col">'.Dokumanlar.'</th>
<th scope="col">'.Haberler.'</th>
</tr>
</table>'
?>

TR.php adında bir sayfa oluşturuyoruz bu sayfa içine;

1
2
3
4
5
6
7
8
<?php
define ("Ana","Anasayfa");
define ("Dersler","Dersler");
define ("Moduller","Modüller");
define ("Dokumanlar","Dökümanlar");
define ("Haberler","Haberler");
?>

EN.php adında bir sayfa oluşturuyoruz bu sayfa içine;

1
2
3
4
5
6
7
<?php
define ("Ana","Home Page");
define ("Dersler","Lessons");
define ("Moduller","Moduls");
define ("Dokumanlar","Documenta");
define ("Haberler","News");
?>

Google açısından diğer sistemlerden daha etkili olduğunu söylebiliriz.