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