/[drupal]/contributions/modules/localizer/localizer_settings.php
ViewVC logotype

Contents of /contributions/modules/localizer/localizer_settings.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Mon Jan 21 09:02:51 2008 UTC (22 months, 1 week ago) by robertogerola
Branch: MAIN
CVS Tags: DRUPAL-5--3-0, HEAD
Changes since 1.2: +1 -1 lines
File MIME type: text/x-php
Added support for language prefix in url aliases
1 <?php
2 function __localizer_get_iso639_list() {
3 static $languages;
4 if(!$languages) {
5 $languages = array(
6 "aa"=>"aa",
7 "ab"=>"ab",
8 "ae"=>"ae",
9 "af"=>"af",
10 "ak"=>"ak",
11 "am"=>"am",
12 "ar"=>"ar",
13 "as"=>"as",
14 "av"=>"av",
15 "ay"=>"ay",
16 "az"=>"az",
17 "ba"=>"ba",
18 "be"=>"be",
19 "bg"=>"bg",
20 "bh"=>"bh",
21 "bi"=>"bi",
22 "bm"=>"bm",
23 "bn"=>"bn",
24 "bo"=>"bo",
25 "br"=>"br",
26 "bs"=>"bs",
27 "ca"=>"ca",
28 "ce"=>"ce",
29 "ch"=>"ch",
30 "co"=>"co",
31 "cr"=>"cr",
32 "cs"=>"cs",
33 "cu"=>"cu",
34 "cv"=>"cv",
35 "cy"=>"cy",
36 "da"=>"da",
37 "de"=>"de",
38 "dv"=>"dv",
39 "dz"=>"dz",
40 "ee"=>"ee",
41 "el"=>"el",
42 "en"=>"en",
43 "eo"=>"eo",
44 "es"=>"es",
45 "et"=>"et",
46 "eu"=>"eu",
47 "fa"=>"fa",
48 "ff"=>"ff",
49 "fi"=>"fi",
50 "fj"=>"fj",
51 "fo"=>"fo",
52 "fr"=>"fr",
53 "fy"=>"fy",
54 "ga"=>"ga",
55 "gd"=>"gd",
56 "gl"=>"gl",
57 "gn"=>"gn",
58 "gu"=>"gu",
59 "gv"=>"gv",
60 "ha"=>"ha",
61 "he"=>"he",
62 "hi"=>"hi",
63 "ho"=>"ho",
64 "hr"=>"hr",
65 "hu"=>"hu",
66 "hy"=>"hy",
67 "hz"=>"hz",
68 "ia"=>"ia",
69 "id"=>"id",
70 "ie"=>"ie",
71 "ig"=>"ig",
72 "ik"=>"ik",
73 "is"=>"is",
74 "it"=>"it",
75 "iu"=>"iu",
76 "ja"=>"ja",
77 "jv"=>"jv",
78 "ka"=>"ka",
79 "kg"=>"kg",
80 "ki"=>"ki",
81 "kj"=>"kj",
82 "kk"=>"kk",
83 "kl"=>"kl",
84 "km"=>"km",
85 "kn"=>"kn",
86 "ko"=>"ko",
87 "kr"=>"kr",
88 "ks"=>"ks",
89 "ku"=>"ku",
90 "kv"=>"kv",
91 "kw"=>"kw",
92 "ky"=>"ky",
93 "la"=>"la",
94 "lb"=>"lb",
95 "lg"=>"lg",
96 "ln"=>"ln",
97 "lo"=>"lo",
98 "lt"=>"lt",
99 "lv"=>"lv",
100 "mg"=>"mg",
101 "mh"=>"mh",
102 "mi"=>"mi",
103 "mk"=>"mk",
104 "ml"=>"ml",
105 "mn"=>"mn",
106 "mo"=>"mo",
107 "mr"=>"mr",
108 "ms"=>"ms",
109 "mt"=>"mt",
110 "my"=>"my",
111 "na"=>"na",
112 "nd"=>"nd",
113 "ne"=>"ne",
114 "ng"=>"ng",
115 "nl"=>"nl",
116 "nl-li"=>"nl-li",
117 "nb"=>"nb",
118 "nn"=>"nn",
119 "nr"=>"nr",
120 "nv"=>"nv",
121 "ny"=>"ny",
122 "oc"=>"oc",
123 "om"=>"om",
124 "or"=>"or",
125 "os"=>"os",
126 "pa"=>"pa",
127 "pi"=>"pi",
128 "pl"=>"pl",
129 "ps"=>"ps",
130 "pt"=>"pt",
131 "pt-br"=>"pt-br",
132 "qu"=>"qu",
133 "rm"=>"rm",
134 "rn"=>"rn",
135 "ro"=>"ro",
136 "ru"=>"ru",
137 "rw"=>"rw",
138 "sa"=>"sa",
139 "sc"=>"sc",
140 "sd"=>"sd",
141 "se"=>"se",
142 "sg"=>"sg",
143 "sh"=>"sh",
144 "si"=>"si",
145 "sk"=>"sk",
146 "sl"=>"sl",
147 "sm"=>"sm",
148 "sn"=>"sn",
149 "so"=>"so",
150 "sq"=>"sq",
151 "sr"=>"sr",
152 "ss"=>"ss",
153 "st"=>"st",
154 "su"=>"su",
155 "sv"=>"sv",
156 "sw"=>"sw",
157 "ta"=>"ta",
158 "te"=>"te",
159 "tg"=>"tg",
160 "th"=>"th",
161 "ti"=>"ti",
162 "tk"=>"tk",
163 "tl"=>"tl",
164 "tn"=>"tn",
165 "to"=>"to",
166 "tr"=>"tr",
167 "ts"=>"ts",
168 "tt"=>"tt",
169 "tw"=>"tw",
170 "ty"=>"ty",
171 "ug"=>"ug",
172 "uk"=>"uk",
173 "ur"=>"ur",
174 "uz"=>"uz",
175 "ve"=>"ve",
176 "vi"=>"vi",
177 "wo"=>"wo",
178 "xh"=>"xh",
179 "yi"=>"yi",
180 "yo"=>"yo",
181 "za"=>"za",
182 "zh-hans"=>"zh-hans",
183 "zh-hant"=>"zh-hant",
184 "zu"=>"zu",
185 );
186 }
187 return $languages;
188 }
189
190 function __localizer_isvalid_language($language = '') {
191 if(($language != '') && array_key_exists($language, __localizer_get_iso639_list())){
192 return true;
193 }
194 else
195 {
196 return false;
197 }
198 }
199
200 function __localizer_path_without_language($path) {
201 $exploded_path = explode('/', $path);
202 $languageinpath = $exploded_path[0];
203 if(__localizer_isvalid_language($languageinpath)){
204 array_shift($exploded_path);
205 return implode("/", $exploded_path);
206 }
207 else
208 {
209 return $path;
210 }
211 }
212
213
214 function __localizer_language_in_path($path) {
215 $exploded_path = explode('/', $path);
216 $languageinpath = $exploded_path[0];
217 if(__localizer_isvalid_language($languageinpath)){
218 return array_shift($exploded_path);
219 }
220 else
221 {
222 return '';
223 }
224 }
225
226 function custom_url_rewrite($type, $path, $original) {
227 if(variable_get('localizer_switch_byhostname', FALSE)) return $path;
228
229 global $__localizer_default_language;
230 global $locale;
231
232 $current_language = $locale;
233 if ($type == 'alias' && $current_language && $current_language != '') {
234 $path = $current_language . '/' . $path;
235 }
236 else if($type == 'source') {
237 if(__localizer_isvalid_language($path)) $path = variable_get('site_frontpage', 'node');
238 $path = __localizer_path_without_language($path);
239 $normal_path = drupal_lookup_path('source', $path);
240 if($normal_path) $path = $normal_path;
241 }
242 return $path;
243 }
244
245 ?>

  ViewVC Help
Powered by ViewVC 1.1.2