e56d23070329276f8a1581c138d414eea8776967
[lhc/web/wiklou.git] / languages / classes / LanguageJa.php
1 <?php
2
3 /**
4 * Japanese (日本語)
5 *
6 * @ingroup Language
7 */
8 class LanguageJa extends Language {
9 function segmentByWord( $string ) {
10 // Strip known punctuation ?
11 // $s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f
12
13 // Space strings of like hiragana/katakana/kanji
14 $hiragana = '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))'; # U3040-309f
15 $katakana = '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))'; # U30a0-30ff
16 $kanji = '(?:\xe3[\x88-\xbf][\x80-\xbf]'
17 . '|[\xe4-\xe8][\x80-\xbf]{2}'
18 . '|\xe9[\x80-\xa5][\x80-\xbf]'
19 . '|\xe9\xa6[\x80-\x99])';
20 # U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99
21 $reg = "/({$hiragana}+|{$katakana}+|{$kanji}+)/";
22 $s = self::insertSpace( $string, $reg );
23 return $s;
24 }
25
26 function normalizeForSearch( $string ) {
27 // Double-width roman characters
28 $s = self::convertDoubleWidth( $string );
29
30 # Do general case folding and UTF-8 armoring
31 return parent::normalizeForSearch( $s );
32 }
33
34 # Italic is not appropriate for Japanese script
35 # Unfortunately most browsers do not recognise this, and render <em> as italic
36 function emphasize( $text ) {
37 return $text;
38 }
39 }