Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Detecting client's natural language

GIJOE
2008-02-21
2013-04-25
  • GIJOE
    GIJOE
    2008-02-21

    I found XCL2.1's installer displays Japanese against any clients because of a typo in a function detecting a language of the client.

    The function uses HTTP_ACCEPT_LANGUAGE and this table.
        $language_array = array(
                'en' => 'english',
                'ja' => 'japanese',
                'fr' => 'french',
                'de' => 'german',
                'nl' => 'dutch',
                'es' => 'spanish',
                'tw' => 'tchinese',
                'cn' => 'schinese',
                'ro' => 'romanian'
        );

    But, some clients like firefox never send HTTP_ACCEPT_LANGUAGE but HTTP_ACCEPT_CHARSET.
    Then, I post a patch detecting languages by HTTP_ACCEPT_CHARSET.
    (eg. If HTTP_ACCEPT_CHARSET contains 'Shift_JIS', the client can read Japanese)

    If you know how to detect YOUR LANGUAGE, please tell us.

    especially users can speak ...

    French
    Greek
    Korean
    Russian
    Zh-tw