| |
| | |

CodersClub

 Forgot password?
 Register
Search
View: 3995|Reply: 3
Collapse the left

Auto detect language for Discuz! ML

[Copy link]
Post time: 2011-12-20 08:05
| Show all posts |Read mode
Edited by vituocgia at 2011-12-20 09:10

Hello!
We are support for Multilingual now
And i think this is much better for user when we have support for automatically detect user languages...Get user language by bellow:
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE', 0, 2);This is a suggestion from me:
<?
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang){
    case "vn":
        //echo "PAGE VN";
        include("index_vn.php");//include check session VN
        break;
    case "it":
        //echo "PAGE CN";
        include("index_vn.php");
        break;
    case "en":
        //echo "PAGE it";
        include("index_it.php");
        break;        
    default:
        //echo "PAGE EN - Setting Default";
        include("index_en.php");//include EN in all other cases of different lang detection
        break;
}
?>

Hope this help Discuz! ML better



 Author| Post time: 2011-12-20 08:08
| Show all posts
Or using this function:We already have an array for languages:
Example we have an array('en', 'vn', 'ar')
function get_client_language($availableLanguages, $default='en'){
       
        if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                       
                $langs=explode(',',$_SERVER['HTTP_ACCEPT_LANGUAGE']);

                //start going through each one
                foreach ($langs as $value){
       
                        $choice=substr($value,0,2);
                        if(in_array($choice, $availableLanguages)){
                                return $choice;
                               
                        }
                       
                }
        }
        return $default;
}



 Russia

Post time: 2011-12-20 09:54
| Show all posts
Did you read this thread (solved)?
http://codersclub.org/discuzx/fo ... &extra=page%3D1

 Author| Post time: 2011-12-21 09:00
| Show all posts
Ok! Sorry i did not check your post ;)
nice
You have to log in before you can reply Login | Register

Points Rules

Archive|Mobile|Dark room|CodersClub

Top.Mail.Ru
Top.Mail.Ru

2024-05-28 08:12 GMT+3 , Processed in 0.052484 sec., 9 queries .

Powered by Discuz! X3.4 Release 20230520

© 2001-2024 Discuz! Team.

MultiLingual version, Rev. 4301, © codersclub.org

Quick Reply To Top Return to the list