Index: trunk/phase3/includes/Setup.php |
— | — | @@ -7,7 +7,6 @@ |
8 | 8 | |
9 | 9 | global $IP; |
10 | 10 | include_once( "$IP/GlobalFunctions.php" ); |
11 | | -include_once( "$IP/Language.php" ); |
12 | 11 | include_once( "$IP/Namespace.php" ); |
13 | 12 | include_once( "$IP/Skin.php" ); |
14 | 13 | include_once( "$IP/OutputPage.php" ); |
— | — | @@ -17,7 +16,7 @@ |
18 | 17 | include_once( "$IP/LinkCache.php" ); |
19 | 18 | include_once( "$IP/Title.php" ); |
20 | 19 | include_once( "$IP/Article.php" ); |
21 | | -require( "$IP/MemCachedClient.inc.php" ); |
| 20 | +include_once( "$IP/MemCachedClient.inc.php" ); |
22 | 21 | |
23 | 22 | wfDebug( "\n\n" ); |
24 | 23 | |
— | — | @@ -37,10 +36,12 @@ |
38 | 37 | $wgMemc->set_debug( $wgMemCachedDebug ); |
39 | 38 | } |
40 | 39 | |
| 40 | +include_once( "$IP/Language.php" ); |
| 41 | + |
41 | 42 | $wgOut = new OutputPage(); |
42 | 43 | $wgLangClass = "Language" . ucfirst( $wgLanguageCode ); |
43 | 44 | if( ! class_exists( $wgLangClass ) ) { |
44 | | - include_once( "$IP/Utf8Case.php" ); |
| 45 | + include_once( "$IP/LanguageUtf8.php" ); |
45 | 46 | $wgLangClass = "LanguageUtf8"; |
46 | 47 | } |
47 | 48 | $wgLang = new $wgLangClass(); |
Index: trunk/phase3/includes/Utf8Case.php |
— | — | @@ -1,13 +1,12 @@ |
2 | 2 | <? |
3 | | -$wgInputEncoding = "utf-8"; |
4 | | -$wgOutputEncoding = "utf-8"; |
5 | | - |
6 | 3 | # Simple 1:1 upper/lowercase switching arrays for utf-8 text |
7 | 4 | # Won't get context-sensitive things yet |
8 | 5 | |
9 | 6 | # Hack for bugs in ucfirst() and company |
10 | | -# TODO: store this in shared memory or something |
11 | 7 | |
| 8 | +# These are pulled from memcached if possible, as this is faster than filling |
| 9 | +# up a big array manually. See also languages/LanguageUtf8.php |
| 10 | + |
12 | 11 | $wikiUpperChars = array( |
13 | 12 | "a" => "A", |
14 | 13 | "b" => "B", |
— | — | @@ -1494,49 +1493,4 @@ |
1495 | 1494 | "\xf0\x90\x90\xa5" => "\xf0\x90\x91\x8d" |
1496 | 1495 | ); |
1497 | 1496 | |
1498 | | -# Base stuff useful to all UTF-8 based language files |
1499 | | -class LanguageUtf8 extends Language { |
1500 | | - |
1501 | | - function ucfirst( $string ) { |
1502 | | - # For most languages, this is a wrapper for ucfirst() |
1503 | | - # But that doesn't work right in a UTF-8 locale |
1504 | | - global $wikiUpperChars, $wikiLowerChars; |
1505 | | - return preg_replace ( |
1506 | | - "/^([\\x00-\\x7f]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", |
1507 | | - "strtr ( \"\$1\" , \$wikiUpperChars )", |
1508 | | - $string ); |
1509 | | - } |
1510 | | - |
1511 | | - function stripForSearch( $string ) { |
1512 | | - # MySQL fulltext index doesn't grok utf-8, so we |
1513 | | - # need to fold cases and convert to hex |
1514 | | - global $wikiLowerChars; |
1515 | | - return preg_replace( |
1516 | | - "/([\\xc0-\\xff][\\x80-\\xbf]*)/e", |
1517 | | - "'U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )", |
1518 | | - $string ); |
1519 | | - } |
1520 | | - |
1521 | | - function fallback8bitEncoding() { |
1522 | | - # Windows codepage 1252 is a superset of iso 8859-1 |
1523 | | - # override this to use difference source encoding to |
1524 | | - # translate incoming 8-bit URLs. |
1525 | | - return "windows-1252"; |
1526 | | - } |
1527 | | - |
1528 | | - function checkTitleEncoding( $s ) { |
1529 | | - global $wgInputEncoding; |
1530 | | - |
1531 | | - # Check for non-UTF-8 URLs |
1532 | | - $ishigh = preg_match( '/[\x80-\xff]/', $s); |
1533 | | - if(!$ishigh) return $s; |
1534 | | - |
1535 | | - $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . |
1536 | | - '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ); |
1537 | | - if( $isutf8 ) return $s; |
1538 | | - |
1539 | | - return $this->iconv( $this->fallback8bitEncoding(), "utf-8", $s ); |
1540 | | - } |
1541 | | -} |
1542 | | - |
1543 | 1497 | ?> |
\ No newline at end of file |
Index: trunk/phase3/languages/LanguageUtf8.php |
— | — | @@ -0,0 +1,60 @@ |
| 2 | +<? |
| 3 | + |
| 4 | +$wgInputEncoding = "utf-8"; |
| 5 | +$wgOutputEncoding = "utf-8"; |
| 6 | + |
| 7 | +$wikiUpperChars = $wgMemc->get( $key1 = "$wgDBname:utf8:upper" ); |
| 8 | +$wikiLowerChars = $wgMemc->get( $key2 = "$wgDBname:utf8:lower" ); |
| 9 | + |
| 10 | +if(($wikiUpperChars === false) || ($wikiLowerChars === false)) { |
| 11 | + include_once("$IP/Utf8Case.php"); |
| 12 | + $wgMemc->set( $key1, $wikiUpperChars ); |
| 13 | + $wgMemc->set( $key2, $wikiLowerChars ); |
| 14 | +} |
| 15 | + |
| 16 | +# Base stuff useful to all UTF-8 based language files |
| 17 | +class LanguageUtf8 extends Language { |
| 18 | + |
| 19 | + function ucfirst( $string ) { |
| 20 | + # For most languages, this is a wrapper for ucfirst() |
| 21 | + # But that doesn't work right in a UTF-8 locale |
| 22 | + global $wikiUpperChars, $wikiLowerChars; |
| 23 | + return preg_replace ( |
| 24 | + "/^([\\x00-\\x7f]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", |
| 25 | + "strtr ( \"\$1\" , \$wikiUpperChars )", |
| 26 | + $string ); |
| 27 | + } |
| 28 | + |
| 29 | + function stripForSearch( $string ) { |
| 30 | + # MySQL fulltext index doesn't grok utf-8, so we |
| 31 | + # need to fold cases and convert to hex |
| 32 | + global $wikiLowerChars; |
| 33 | + return preg_replace( |
| 34 | + "/([\\xc0-\\xff][\\x80-\\xbf]*)/e", |
| 35 | + "'U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )", |
| 36 | + $string ); |
| 37 | + } |
| 38 | + |
| 39 | + function fallback8bitEncoding() { |
| 40 | + # Windows codepage 1252 is a superset of iso 8859-1 |
| 41 | + # override this to use difference source encoding to |
| 42 | + # translate incoming 8-bit URLs. |
| 43 | + return "windows-1252"; |
| 44 | + } |
| 45 | + |
| 46 | + function checkTitleEncoding( $s ) { |
| 47 | + global $wgInputEncoding; |
| 48 | + |
| 49 | + # Check for non-UTF-8 URLs |
| 50 | + $ishigh = preg_match( '/[\x80-\xff]/', $s); |
| 51 | + if(!$ishigh) return $s; |
| 52 | + |
| 53 | + $isutf8 = preg_match( '/^([\x00-\x7f]|[\xc0-\xdf][\x80-\xbf]|' . |
| 54 | + '[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xf7][\x80-\xbf]{3})+$/', $s ); |
| 55 | + if( $isutf8 ) return $s; |
| 56 | + |
| 57 | + return $this->iconv( $this->fallback8bitEncoding(), "utf-8", $s ); |
| 58 | + } |
| 59 | +} |
| 60 | + |
| 61 | +?> |
Property changes on: trunk/phase3/languages/LanguageUtf8.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 62 | + native |
Added: svn:keywords |
2 | 63 | + Author Date Id Revision |
Index: trunk/phase3/languages/LanguageJa.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <?php |
3 | 3 | global $IP; |
4 | | -include_once( "$IP/Utf8Case.php" ); |
| 4 | +include_once( "$IP/LanguageUtf8.php" ); |
5 | 5 | |
6 | 6 | # The names of the namespaces can be set here, but the numbers |
7 | 7 | # are magical, so don't change or move them! The Namespace class |
Index: trunk/phase3/languages/LanguageHe.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | 3 | |
4 | | -include_once("Utf8Case.php"); |
| 4 | +include_once("LanguageUtf8.php"); |
5 | 5 | |
6 | 6 | # NOTE: To turn off "Current Events" in the sidebar, |
7 | 7 | # set "currentevents" => "-" |
Index: trunk/phase3/languages/LanguageHi.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | 3 | |
4 | | -include( "Utf8Case.php" ); |
| 4 | +include( "LanguageUtf8.php" ); |
5 | 5 | |
6 | 6 | # NOTE: To turn off "Current Events" in the sidebar, |
7 | 7 | # set "currentevents" => "-" |
Index: trunk/phase3/languages/LanguageAr.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | 3 | # See language.doc |
4 | | -include_once("Utf8Case.php"); |
| 4 | +include_once("LanguageUtf8.php"); |
5 | 5 | |
6 | 6 | class LanguageAr extends LanguageUtf8 { |
7 | 7 | # TODO: TRANSLATION! |
Index: trunk/phase3/languages/LanguageEo.php |
— | — | @@ -1,7 +1,5 @@ |
2 | 2 | <? |
3 | | -include("Utf8Case.php"); |
4 | | -$wgInputEncoding = "utf-8"; |
5 | | -$wgOutputEncoding = "utf-8"; |
| 3 | +include("LanguageUtf8.php"); |
6 | 4 | $wgEditEncoding = "x"; |
7 | 5 | |
8 | 6 | # See language.doc |
Index: trunk/phase3/languages/LanguageMl.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <? |
3 | 3 | # See language.doc |
4 | 4 | |
5 | | -include_once( "Utf8Case.php" ); |
| 5 | +include_once( "LanguageUtf8.php" ); |
6 | 6 | |
7 | 7 | class LanguageMl extends LanguageUtf8 { |
8 | 8 | # Inherit everything |
Index: trunk/phase3/languages/LanguageKo.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | 3 | global $IP; |
4 | | -include_once( "$IP/Utf8Case.php" ); |
| 4 | +include_once( "$IP/LanguageUtf8.php" ); |
5 | 5 | |
6 | 6 | # The names of the namespaces can be set here, but the numbers |
7 | 7 | # are magical, so don't change or move them! The Namespace class |
Index: trunk/phase3/languages/LanguageHu.php |
— | — | @@ -1,6 +1,6 @@ |
2 | 2 | <? |
3 | 3 | |
4 | | -include_once("Utf8Case.php"); |
| 4 | +include_once("LanguageUtf8.php"); |
5 | 5 | |
6 | 6 | # NOTE: To turn off "Current Events" in the sidebar, |
7 | 7 | # set "currentevents" => "-" |
Index: trunk/phase3/languages/Language.php |
— | — | @@ -276,7 +276,7 @@ |
277 | 277 | "Recentchangeslinked" => "", |
278 | 278 | "Movepage" => "", |
279 | 279 | "Booksources" => "External book sources", |
280 | | -"Categories" => "Page categories", |
| 280 | +"Categories" => "Page categories" |
281 | 281 | ); |
282 | 282 | |
283 | 283 | /* private */ $wgSysopSpecialPagesEn = array( |