-
- /**
- * Convert the input to a different language variant
- *
- * @param string $text input text
- * @param string $tolang language variant
- * @return string the converted text
- * @access public
- */
- function convert($text, $tolang) {
- $t = '';
- switch($tolang) {
- case 'zh-cn':
- $t = $this->zh2cn($text);
- break;
- case 'zh-tw':
- $t = $this->zh2tw($text);
- break;
- case 'zh-sg':
- $t = $this->zh2sg($text);
- break;
- case 'zh-hk':
- $t = $this->zh2hk($text);
- break;
- default:
- $t = $text;
- }
- return $t;
- }
-
- function convertToAllVariants($text) {
- $ret = array();
- $ret['zh-cn'] = $this->zh2cn($text);
- $ret['zh-tw'] = $this->zh2tw($text);
- $ret['zh-sg'] = $this->zh2sg($text);
- $ret['zh-hk'] = $this->zh2hk($text);
- return $ret;
- }
-
- /**
- * Perform "fake" word segmentation, i.e. treating each character as a word
- *
- * @param string $text input text
- * @return string segmented text
- * @access public
- */
- function segment($text) {
- /* copied from LanguageZh_cn.stripForSearch() */
- if( function_exists( 'mb_strtolower' ) ) {
- return preg_replace(
- "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "' U8' . bin2hex( \"$1\" )",
- mb_strtolower( $text ) );
- } else {
- global $wikiLowerChars;
- return preg_replace(
- "/([\\xc0-\\xff][\\x80-\\xbf]*)/e",
- "' U8' . bin2hex( strtr( \"\$1\", \$wikiLowerChars ) )",
- $text );
- }
- }
-
- /**
- * Close the fake connection
- *
- * @access public
- */
- function close() { }