Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1432461
LanguageZh.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
LanguageZh.php
View Options
<?php
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/
/**
* Chinese-specific code.
*
* This handles both Traditional and Simplified Chinese.
* Right now, we distinguish `zh_hans`, `zh_hant`, `zh_cn`, `zh_tw`, `zh_sg`,
* and `zh_hk`.
*
* @ingroup Languages
*/
class
LanguageZh
extends
LanguageZh_hans
{
/**
* Add a formfeed character between each non-ASCII character, so that
* "word-level" diffs will effectively operate on a character level. The FF
* characters are stripped out by unsegmentForDiff().
*
* We use FF because it is the least used character that is matched by
* PCRE's \s class.
*
* In the unlikely event that an FF character appears in the input, it will
* be displayed in the diff as a replacement character.
*
* @param string $text
* @return string
*/
public
function
segmentForDiff
(
$text
)
{
$text
=
str_replace
(
"
\x
0c"
,
"
\u
{FFFD}"
,
$text
);
return
preg_replace
(
'/[
\x
c0-
\x
ff][
\x
80-
\x
bf]*/'
,
"
\x
0c$0"
,
$text
);
}
public
function
unsegmentForDiff
(
$text
)
{
return
str_replace
(
"
\x
0c"
,
''
,
$text
);
}
protected
function
getSearchIndexVariant
()
{
return
'zh-hans'
;
}
public
function
convertForSearchResult
(
$termsArray
)
{
$terms
=
implode
(
'|'
,
$termsArray
);
$terms
=
self
::
convertDoubleWidth
(
$terms
);
$terms
=
implode
(
'|'
,
$this
->
getConverterInternal
()->
autoConvertToAllVariants
(
$terms
)
);
return
array_unique
(
explode
(
'|'
,
$terms
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:47 (1 d, 6 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
be/56/350bec572f1da35cb6d5970e0aa7
Default Alt Text
LanguageZh.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment