]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - languages/classes/LanguageEo.php
MediaWiki 1.11.0
[autoinstallsdev/mediawiki.git] / languages / classes / LanguageEo.php
1 <?php
2 /** Esperanto (Esperanto)
3   * @addtogroup Language
4   */
5
6 class LanguageEo extends Language {
7         function iconv( $in, $out, $string ) {
8                 # For most languages, this is a wrapper for iconv
9                 # Por multaj lingvoj, ĉi tiu nur voku la sisteman funkcion iconv()
10                 # Ni ankaŭ konvertu X-sistemajn surogotajn
11                 if( strcasecmp( $in, 'x' ) == 0 and strcasecmp( $out, 'utf-8' ) == 0) {
12                         $xu = array (
13                                 'xx' => 'x' , 'xX' => 'x' ,
14                                 'Xx' => 'X' , 'XX' => 'X' ,
15                                 "Cx" => "\xc4\x88" , "CX" => "\xc4\x88" ,
16                                 "cx" => "\xc4\x89" , "cX" => "\xc4\x89" ,
17                                 "Gx" => "\xc4\x9c" , "GX" => "\xc4\x9c" ,
18                                 "gx" => "\xc4\x9d" , "gX" => "\xc4\x9d" ,
19                                 "Hx" => "\xc4\xa4" , "HX" => "\xc4\xa4" ,
20                                 "hx" => "\xc4\xa5" , "hX" => "\xc4\xa5" ,
21                                 "Jx" => "\xc4\xb4" , "JX" => "\xc4\xb4" ,
22                                 "jx" => "\xc4\xb5" , "jX" => "\xc4\xb5" ,
23                                 "Sx" => "\xc5\x9c" , "SX" => "\xc5\x9c" ,
24                                 "sx" => "\xc5\x9d" , "sX" => "\xc5\x9d" ,
25                                 "Ux" => "\xc5\xac" , "UX" => "\xc5\xac" ,
26                                 "ux" => "\xc5\xad" , "uX" => "\xc5\xad"
27                                 ) ;
28                         return preg_replace ( '/([cghjsu]x?)((?:xx)*)(?!x)/ei',
29                           'strtr( "$1", $xu ) . strtr( "$2", $xu )', $string );
30                 } else if( strcasecmp( $in, 'UTF-8' ) == 0 and strcasecmp( $out, 'x' ) == 0 ) {
31                         $ux = array (
32                                 'x' => 'xx' , 'X' => 'Xx' ,
33                                 "\xc4\x88" => "Cx" , "\xc4\x89" => "cx" ,
34                                 "\xc4\x9c" => "Gx" , "\xc4\x9d" => "gx" ,
35                                 "\xc4\xa4" => "Hx" , "\xc4\xa5" => "hx" ,
36                                 "\xc4\xb4" => "Jx" , "\xc4\xb5" => "jx" ,
37                                 "\xc5\x9c" => "Sx" , "\xc5\x9d" => "sx" ,
38                                 "\xc5\xac" => "Ux" , "\xc5\xad" => "ux"
39                         ) ;
40                         # Double Xs only if they follow cxapelutaj literoj.
41                         return preg_replace( '/((?:[cghjsu]|\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
42                           '|\xc5[\x9c\x9d\xac\xad])x*)/ei', 'strtr( "$1", $ux )', $string );
43                 }
44                 return iconv( $in, $out, $string );
45         }
46
47         function checkTitleEncoding( $s ) {
48                 # Check for X-system backwards-compatibility URLs
49                 $ishigh = preg_match( '/[\x80-\xff]/', $s);
50                 $isutf = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' .
51                         '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s );
52
53                 if($ishigh and !$isutf) {
54                         # Assume Latin1
55                         $s = utf8_encode( $s );
56                 } else {
57                         if( preg_match( '/(\xc4[\x88\x89\x9c\x9d\xa4\xa5\xb4\xb5]'.
58                                 '|\xc5[\x9c\x9d\xac\xad])/', $s ) )
59                         return $s;
60                 }
61
62                 //if( preg_match( '/[cghjsu]x/i', $s ) )
63                 //      return $this->iconv( 'x', 'utf-8', $s );
64                 return $s;
65         }
66
67         function initEncoding() {
68                 global $wgEditEncoding;
69                 $wgEditEncoding = 'x';
70         }
71 }
72
73