/**
 * Set the locale with parameter, for UNIX and Windows OS.
 * @param string locType locale identifier string.
 * @return boolean If true, strings with locale are possibly multi-byte string.
 */
function setLocaleAsBrowser($locType)
{
    $lstr = getLocaleFromBrowser(!isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? 'ja_JP' : $_SERVER['HTTP_ACCEPT_LANGUAGE']);
    // Detect server platform, Windows or Unix
    $isWindows = false;
    $uname = php_uname();
    if (strpos($uname, 'Windows')) {
        $isWindows = true;
    }
    $useMbstring = false;
    if ($lstr == 'ja_JP') {
        $useMbstring = true;
        if ($isWindows) {
            setlocale($locType, 'jpn_jpn');
        } else {
            setlocale($locType, 'ja_JP');
        }
    } else {
        if ($lstr == 'ja') {
            $useMbstring = true;
            if ($isWindows) {
                setlocale($locType, 'jpn_jpn');
            } else {
                setlocale($locType, 'ja_JP');
            }
        } else {
            if ($lstr == 'en_US') {
                if ($isWindows) {
                    setlocale($locType, 'jpn_jpn');
                } else {
                    setlocale($locType, 'en_US');
                }
            } else {
                if ($lstr == 'en') {
                    if ($isWindows) {
                        setlocale($locType, 'jpn_jpn');
                    } else {
                        setlocale($locType, 'en_US');
                    }
                } else {
                    setlocale($locType, '');
                }
            }
        }
    }
    return $useMbstring;
}
 public function test_getLocaleFromBrowser()
 {
     $testName = "Check getLocaleFromBrowser function in INTER-Mediator.php.";
     $headerStr = "ja";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "ja", $testName);
     $headerStr = "ja_JP";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "ja_JP", $testName);
     $headerStr = "en_US";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "en_US", $testName);
     $headerStr = "ja, en";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "ja", $testName);
     $headerStr = "en, ja";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "en", $testName);
     $headerStr = "ja; q=1.0, en; q=0.1";
     $locStr = getLocaleFromBrowser($headerStr);
     $this->assertTrue($locStr == "ja", $testName);
     //        $headerStr = "ja; q=0.1, en; q=1.0";
     //        $locStr = getLocaleFromBrowser($headerStr);
     //        $this->assertTrue($locStr == "en", $testName);
 }