开发者

Php for a bilingual site

Is it possible using php, for a user to click on a english/french toggle button, that would then read the current url, and match it to the french version of the page?

Thank you for your time.开发者_开发问答


When the users clicks the button, populate a session variable with the selected language:

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

Then use templates to store your language-specific information. When you load the template, include the language code

// 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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜