Stripping CVS keywords
[project/i18n.git] / i18n.inc
1 <?php
2
3 /**
4 * Conditional definition of conf_url_rewrite
5 *
6 */
7
8 function conf_url_rewrite($path, $mode = 'incoming') {
9 if(variable_get('i18n_keep','')=='url'){
10 return i18n_url_rewrite($path,$mode);
11 } else {
12 return $path;
13 }
14 }
15
16 function i18n_url_rewrite($path, $mode = 'incoming') {
17 global $i18n_langpath;
18 if ($mode == 'incoming') { // URL coming from a client
19 if($i18n_langpath=i18n_get_lang_prefix($path)){
20 // Remove language from path and try to find alias for new path
21 $path=substr($path,3);
22 return drupal_get_normal_path($path);
23 } else {
24 return $path;
25 }
26
27 }
28 else { // URL going out to a client
29 if($i18n_langpath){
30 return "$i18n_langpath/$path";
31 } else {
32 return $path;
33 }
34 }
35 }
36
37 // Get language from path, but only if it is in the $languages array
38 function i18n_get_lang_prefix($path){
39 global $languages;
40 $split=split("/",$path);
41 $maybelang=$split[0];
42 if($languages[$maybelang]){
43 return $maybelang;
44 }
45 }
46 ?>