|
|
|
If you're looking to code a multilingue website, this is a technique i used in many solutions, specially for text that is inside a php code.
|
<?php
/**
* index.php
* multilingual website
* lang/index.fr.php French translation
* lang/index.en.php English translation
*
* @author Hatem <hatem@php.net>
* @version 1.1.0 27 février 2002
*/
/**
* Detect and include language
*/
session_start();
if(!isset($lang)) {
$lang = getenv('HTTP_ACCEPT_LANGUAGE');
$lang_default = "en";
}
if (is_file("lang/index.$lang.php"))
{
$_SESSION["lang"] = $lang;
include("lang/index.$lang.php");
} else {
$_SESSION["lang"] = $lang_default;
include("lang/index.$lang_default.php");
}
/**
* Then code your website here
*/
echo _HELLO_;
echo "\n"._INFO_;
?> | |
| <?php
/**
* lang/index.en.php
*/
define("_HELLO_", "Hello");
define("_INFO_", "This web site support english and french");
?> | |
| <?php
/**
* lang/index.fr.php
*/
define("_HELLO_", "Salut");
define("_INFO_", "Ce site web supporte l'anglais et le français");
?> | | |
|
| A login page that require username, password and userlevel. Categories : PHP, Security, Sessions, MySQL, Databases | | | Optimized Online users class Categories : PHP, PHP Classes, Sessions | | | Demo of Alternate Pagination Paradigm (Paging) Categories : PHP, User Interface, Sessions | | | base64 with encryption - encode and decode sessions Categories : PHP, PHP Classes, Encryption, Sessions | | | XDT Topsite (Gold v1.0) Categories : Databases, CSS, PHP, HTML and PHP, Sessions | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | A simple PHP login script that you can modify to suite your needs. It use a session to store data in a session file submited by the page. Categories : PHP, Sessions, Security, Authentication | | | session out Timer Categories : PHP, Sessions, Security, Beginner Guides | | | O-LOC : PHP 5.x Internationalization class and back-office. manage the display of translations on a localized web application. Categories : PHP, PHP Classes, Web Applications, Languages, DOM XML | | | translate.php - Assocciative array example, passing a reference to a function. Categories : PHP, Arrays, Languages, Variables | | | Problem passing session variables Categories : Sessions, PHP | | | CAPTCHA[Image verification] Categories : PHP, Security, GD image library, Graphics, Sessions | | | SPL and ITERATOR : examples Categories : PHP, Object Oriented, PHP Classes, Sessions | | | Prevent multi submit Categories : PHP, Sessions | | | session_cache_limiter -- Get and/or set the current cache limiter Categories : PHP, PHP Functions, Sessions | |
|
|