Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 PHP Code: Language Specific Response Jump to:  
Category: >> PHP Code >> Language Specific Response Bookmark and Share

<< lastnext >>

Snippet Name: Language Specific Response

Description: Ever wanted to give response to the users in the language they prefer? Most browsers pass the language preference using the HTTP header ‘Accept-Language’ which looks like ‘Accept-Language: en-us,en;q=0.5‘. We can use this to detect the users first preferred language and show the response in that language.

Using the variable '$languages[0]' we can redirect the page to the language specific URL, include a particular language file, etc to achieve the language specific response.

We can also have a list of languages we support in an array and keep looping through the array '$languages' and comparing the two, we can easily find the languages that we support and is preferred by the browser.

Comment: (none)

Language: PHP
Highlight Mode: PHP
Last Modified: March 01st, 2009

<?PHP
 
$languages_supported_by_browser=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
 
$pos=STRPOS($languages_supported_by_browser,";");
 
IF ($pos>0) {
    $languages_supported_by_browser =
        SUBSTR($languages_supported_by_browser,0,$pos);
}
 
$languages=SPLIT(",",$languages_supported_by_browser);
 
ECHO "First language supported by browser is: ".
        $languages[0].".";
 
?>
 
 


Free
Oracle Magazine
Subscriptions
and Oracle White Papers


SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 58 users online    © 2009 psoug.org

PSOUG LOGIN
Username: 
Password: 
Forgot your password?