Subversion Repositories svnkaklik

Rev

Details | Last modification | View Log

Rev Author Line No. Line
6 kaklik 1
<?php
2
/*************************
3
  Coppermine Photo Gallery
4
  ************************
5
  Copyright (c) 2003-2005 Coppermine Dev Team
6
  v1.1 originaly written by Gregory DEMAR
7
 
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
  ********************************************
13
  Coppermine version: 1.3.3
14
  $Source: /cvsroot/coppermine/stable/include/select_lang.inc.php,v $
15
  $Revision: 1.7 $
16
  $Author: gaugau $
17
  $Date: 2005/04/19 03:17:11 $
18
**********************************************/
19
 
20
/**
21
 * phpMyAdmin Language Loading File
22
 */
23
 
24
/**
25
 * All the supported languages have to be listed in the array below.
26
 * 1. The key must be the "official" ISO 639 language code and, if required,
27
 *     the dialect code. It can also contains some informations about the
28
 *     charset (see the Russian case).
29
 * 2. The first of the values associated to the key is used in a regular
30
 *     expression to find some keywords corresponding to the language inside two
31
 *     environment variables.
32
 *     These values contains:
33
 *     - the "official" ISO language code and, if required, the dialect code
34
 *       also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
35
 *       dialects, 'zh[-_]tw' for Chinese traditional...);
36
 *     - the '|' character (it means 'OR');
37
 *     - the full language name.
38
 * 3. The second values associated to the key is the name of the file to load
39
 *     without the '.php' extension.
40
 * 4. The last values associated to the key is the language code as defined by
41
 *     the RFC1766.
42
 *
43
 * Beware that the sorting order (first values associated to keys by
44
 * alphabetical reverse order in the array) is important: 'zh-tw' (chinese
45
 * traditional) must be detected before 'zh' (chinese simplified) for
46
 * example.
47
 *
48
 * When there are more than one charset for a language, we put the -utf-8
49
 * first.
50
 */
51
$available_languages = array('ar' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
52
    'bg' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'),
53
    'ca' => array('ca|catalan', 'catalan-utf-8', 'ca'),
54
    'cs' => array('cs|czech', 'czech-utf-8', 'cs'),
55
    'da' => array('da|danish', 'danish-utf-8', 'da'),
56
    'de' => array('de([-_][[:alpha:]]{2})?|german', 'german-utf-8', 'de'),
57
    'el' => array('el|greek', 'greek-utf-8', 'el'),
58
    'en' => array('en([-_][[:alpha:]]{2})?|english', 'english-utf-8', 'en'),
59
    'es' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-utf-8', 'es'),
60
    'et' => array('et|estonian', 'estonian-utf-8', 'et'),
61
    'fi' => array('fi|finnish', 'finnish-utf-8', 'fi'),
62
    'fr' => array('fr([-_][[:alpha:]]{2})?|french', 'french-utf-8', 'fr'),
63
    'gl' => array('gl|galician', 'galician-utf-8', 'gl'),
64
    'he' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he'),
65
    'hr' => array('hr|croatian', 'croatian-utf-8', 'hr'),
66
    'hu' => array('hu|hungarian', 'hungarian-utf-8', 'hu'),
67
    'id' => array('id|indonesian', 'indonesian-utf-8', 'id'),
68
    'it' => array('it|italian', 'italian-utf-8', 'it'),
69
    'ja' => array('ja|japanese', 'japanese-utf-8', 'ja'),
70
    'ko' => array('ko|korean', 'korean-ks_c_5601-1987', 'ko'),
71
    'ka' => array('ka|georgian', 'georgian-utf-8', 'ka'),
72
    'lt' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'),
73
    'lv' => array('lv|latvian', 'latvian-utf-8', 'lv'),
74
    'nl' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-utf-8', 'nl'),
75
    'no' => array('no|norwegian', 'norwegian-utf-8', 'no'),
76
    'pl' => array('pl|polish', 'polish-utf-8', 'pl'),
77
    'pt' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'),
78
    'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-utf-8', 'pt'),
79
    'ro' => array('ro|romanian', 'romanian-utf-8', 'ro'),
80
    'ru' => array('ru|russian', 'russian-utf-8', 'ru'),
81
    'sk' => array('sk|slovak', 'slovak-utf-8', 'sk'),
82
        'sl' => array('sl|slovenian', 'slovenian-utf-8', 'sl'),
83
    'sq' => array('sq|albanian', 'albanian-utf-8', 'sq'),
84
    'sr' => array('sr|serbian', 'serbian-utf-8', 'sr'),
85
    'sv' => array('sv|swedish', 'swedish-utf-8', 'sv'),
86
    'th' => array('th|thai', 'thai-utf-8', 'th'),
87
    'tr' => array('tr|turkish', 'turkish-utf-8', 'tr'),
88
    'uk' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'),
89
    'zh' => array('zh[-_]tw|chinese traditional', 'chinese_big5-utf-8', 'zh-TW'),
90
    'zh' => array('zh|chinese simplified', 'chinese_gb-utf-8', 'zh'),
91
    );
92
 
93
/**
94
 * Analyzes some PHP environment variables to find the most probable language
95
 * that should be used
96
 *
97
 * @param string $ string to analyze
98
 * @param integer $ type of the PHP environment variable which value is $str
99
 * @global array    the list of available translations
100
 * @global string   the retained translation keyword
101
 * @access private
102
 */
103
function lang_detect($str = '', $envType = '')
104
{
105
    global $available_languages;
106
    global $lang;
107
 
108
    reset($available_languages);
109
    while (list($key, $value) = each($available_languages)) {
110
        // $envType =  1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
111
        // 2 for the 'HTTP_USER_AGENT' one
112
        if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str)) || ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
113
            $lang = $key;
114
            break;
115
        }
116
    }
117
}
118
 
119
/**
120
 * Get some global variables if 'register_globals' is set to 'off'
121
 * loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
122
 */
123
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
124
    $HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
125
} else if (!empty($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) {
126
    $HTTP_ACCEPT_LANGUAGE = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
127
}
128
 
129
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
130
    $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
131
} else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
132
    $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
133
}
134
 
135
/**
136
 * Do the work!
137
 */
138
 
139
$lang = '';
140
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
141
// variable
142
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
143
    $accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
144
    $acceptedCnt = count($accepted);
145
    reset($accepted);
146
    for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
147
        lang_detect($accepted[$i], 1);
148
    }
149
}
150
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
151
if (empty($lang) && !empty($HTTP_USER_AGENT)) {
152
    lang_detect($HTTP_USER_AGENT, 2);
153
}
154
// 3. If we catch a valid language, configure it
155
if (!empty($lang)) {
156
    $USER['lang'] = $available_languages[$lang][1];
157
}
158
// $__PMA_SELECT_LANG_LIB__
159
?>