Quick Search:
 PHP Code: Language Specific Response Jump to:  
Category: >> PHP Code >> Language Specific Response  

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

IF ($pos>0) {
    $languages_supported_by_browser =
ECHO "First language supported by browser is: ".

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org