From 9d51f61661c821ef3fcf3de6f822717b0c6742f2 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Wed, 2 Jul 2003 07:29:54 +0000 Subject: [PATCH] Add zh-cn and zh-tw language prefixes in order to label simplified and traditional chinese; for now these both still point to zh.wikipedia.org, but are labeled differently in the interlanguage link list. Also, regexps expanded to better handle hypenated language codes --- includes/Interwiki.php | 2 ++ includes/OutputPage.php | 2 +- includes/Title.php | 6 ++++-- languages/Language.php | 2 ++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/Interwiki.php b/includes/Interwiki.php index e5e97aa60d..8f2dd7c855 100644 --- a/includes/Interwiki.php +++ b/includes/Interwiki.php @@ -258,6 +258,8 @@ $WikiPediaLanguages = array( "yo" => "http://yo.wikipedia.com/wiki.cgi?$1", "za" => "http://za.wikipedia.com/wiki.cgi?$1", "zh" => "http://zh.wikipedia.org/wiki/$1", + "zh-cn" => "http://zh.wikipedia.org/wiki/$1", + "zh-tw" => "http://zh.wikipedia.org/wiki/$1", "zu" => "http://zu.wikipedia.com/wiki.cgi?$1", "nds" => "http://nds.wikipedia.org/wiki.cgi?$1" ); diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 50748e4723..a753d717d5 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -834,7 +834,7 @@ class OutputPage { $link = $m[1]; } - if ( preg_match( "/^([A-Za-z\\x80-\\xff]+):(.*)\$/", $link, $m ) ) { + if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z\\x80-\\xff]+):(.*)\$/", $link, $m ) ) { $pre = strtolower( $m[1] ); $suf = $m[2]; if ( $wgLang->getNsIndex( $pre ) == diff --git a/includes/Title.php b/includes/Title.php index f870526db2..0df3f6c720 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -73,7 +73,9 @@ class Title { return "-,.()' &;%!?_0-9A-Za-z\\/:\\x80-\\xFF"; } else { # ISO 8859-* don't allow 0x80-0x9F - return "-,.()' &;%!?_0-9A-Za-z\\/:\\xA0-\\xFF"; + #return "-,.()' &;%!?_0-9A-Za-z\\/:\\xA0-\\xFF"; + # But that breaks interlanguage links at the moment. Temporary: + return "-,.()' &;%!?_0-9A-Za-z\\/:\\x80-\\xFF"; } } @@ -324,7 +326,7 @@ class Title { if ( ":" == $t{0} ) { $r = substr( $t, 1 ); } else { - if ( preg_match( "/^([A-Za-z0-9_\\x80-\\xff]+):(.*)$/", $t, $m ) ) { + if ( preg_match( "/^((?:i|x|[a-z]{2,3})(?:-[a-z0-9]+)?|[A-Za-z0-9_\\x80-\\xff]+):(.*)$/", $t, $m ) ) { #$p = strtolower( $m[1] ); $p = $m[1]; if ( array_key_exists( $p, $wgValidInterwikis ) ) { diff --git a/languages/Language.php b/languages/Language.php index dfe4ebd470..acb5156ac9 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -217,6 +217,8 @@ this (alternative: like this?).", "yo" => "Yoruba", "za" => "Zhuang", "zh" => "中文 (Zhongwen)", + "zh-cn" => "中文(简体) (Simplified Chinese)", + "zh-tw" => "中文(繁体) (Traditional Chinese)", "zu" => "Zulu" ); -- 2.20.1