0
好了,所以我得到的類文件,其中我得到的功能 - 如果我通過這樣的index.php翻譯創建多語言翻譯網頁
var $text;
public function languages()
{
if (isset($_GET['lang']) && $_GET['lang'] != '')
{
$_SESSION['lang'] = $_GET['lang'];
}
switch($_SESSION['lang'])
{
case 'en_EN': require_once('language/lang.eng.php');break;
case 'lv_LV': require_once('language/lang.lv.php');break;
case 'ru_RU': require_once('language/lang.ru.php');break;
default: require_once('language/lang.eng.php');
}
$this->text = $text;
}
public function translate($txt)
{
if(isset($this->text[$txt]))
{
return $this->text[$txt];
}
}
- >echo $index->translate('search');
它轉換好的,但如果我正在翻譯例如類文件中的東西 -
if ($country_rows > 0)
{
$_SESSION['country'] = $_GET['country'];
}
else
{
$_SESSION['country'] = $this->translate('all_countries');
}
}
if ($_SESSION['country'] == '')
{
$_SESSION['country'] = $this->translate('all_countries');
}
它沒有顯示出來。 在index.php文件頭我得到了包括 -
require_once('class.index.php');
$index = new index;
$index->get_country();
$index->languages();
可能是什麼問題,以及如何解決它,所以我可以翻譯類文件裏面也一切?將感謝您的幫助!
我們只看到星星點點這裏。你能解決這個問題嗎? – afuzzyllama
好吧,正如我所說的,在類文件$ this-> translate('smth_here');不工作,它不會顯示任何東西,但在index.php我定義類索引; $首頁 - >翻譯( 'smth_here');它會翻譯得很好。 – user980952