2011-09-26 60 views
-1

是否有可能使用php,让用户点击英文/法文切换按钮,然后读取当前网址,并将其与法语版本的网页相匹配?Php双语网站

谢谢你的时间。

+0

PHP 5.3? http://devzone.zend.com/article/4799 – Coffee

+0

Adel,我想你错过了这一点。 OP似乎没有试图本地化特定的数据片段,而是改变整个网站的语言。 –

回答

0

当用户点击这个按钮,填写一个会话变量与所选择的语言:

session_start(); 
$_SESSION['language'] = 'FR'; // Or 'EN', etc 

然后使用模板来存储您的特定语言信息。当你加载模板时,包含语言代码

// Load a template 
Template::load('<page_name>', $_SESSION['language']); 


// Where the `load()` method looks something like this: 
public function load($page_name, $language) { 
    // Construct the path to the template 
    $file_handle = fopen(PATH_TO_TEMPLATES . $language . "/" . $page_name); 

    // Do something with the template here. 
} 
+0

感谢您的快速响应。我认为我的问题是所有的页面都被开发出来了。英语在一个文件夹中,而法语在另一个文件夹中。我在导航中有一个实用程序部分,它是作为一个PHP包装加载的。 我的问题是,是否有一个PHP脚本,点击将抓住当前页面的网址,并匹配到它的法国等值?我猜我们需要每个页面的变量列表(例如http://site.com/tools/calculator.php= http://site.com/tools/calculatrice.php)这是否有意义? – Robbie