我也同意分它會根據您的需求創建文件。
既然你想要文本文件,這是一個非常原始的只是爲了演示示例與文本文件。不過,我認爲使用靜態類可以看起來比簡單的常量更有組織。
./index.php
<?php
session_start();
///////////////////////////////// LANGUAGE ///////////////////////////////////
if(!isset($_SESSION['langid']))/*This will run only once*/
$_SESSION['langid']="en";//persistent store
if(isset($_GET['langid']))
$_SESSION['langid']=$_GET['langid'];//persistent store
/*** define the path ***/
define ('__LANG_PATH', 'C:/wamp/www/lang/lang/'.$_SESSION['langid'].'/');
echo"
<a href=index.php?langid=en>English</a><br>
<a href=index.php?langid=fr>French</a><br><br>";
include('history.php');
?>
./history.php
<?PHP
include __LANG_PATH.'txtHistory.inc';
echo txtArticle::$body_title;
echo '<br>';
echo txtArticle::$history_article
?>
./lang/en/txtHistory.inc
<?PHP
class txtArticle
{
public static $body_title="Welcome to history page..";
public static $history_article=
"Based at RAF Medmenham, a country house on the banks of the
Thames, the Central Interpretation Unit (CIU) was established in
April 1941. .";
}
?>
./lang/fr/txtHistory.inc
<?PHP
class txtArticle
{
public static $body_title="Bienvenue à la page d'histoire..";
public static $history_article=
"Basé à la RAF Medmenham, une maison de campagne sur les
leur travail, les opérations de l'OPC et la guerre, qui incluse guider
les raids de la Dam Busters, a été largement méconnus jusqu'à présent.
";
}
?>
你有沒有看着[gettext的(http://php.net/manual/en/book.gettext.php)? –
是的,我對gettext很熟悉,但我想控制翻譯文本,所以我避開了外部服務。 – user1002039
不確定你的意思是關於gettext作爲外部服務。您可以自己提供翻譯文件。 –