我也同意分它会根据您的需求创建文件。
既然你想要文本文件,这是一个非常原始的只是为了演示示例与文本文件。不过,我认为使用静态类可以看起来比简单的常量更有组织。
./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作为外部服务。您可以自己提供翻译文件。 –