removing unused globals and some whitespace cleaning
[lhc/web/wiklou.git] / languages / LanguageJa.php
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage Language
5 */
6 global $IP;
7 require_once( "LanguageUtf8.php" );
8
9 /* private */ $wgNamespaceNamesJa = array(
10 NS_MEDIA => "Media", /* Media */
11 NS_SPECIAL => "特別", /* Special */
12 NS_MAIN => "",
13 NS_TALK => "ノート", /* Talk */
14 NS_USER => "利用者", /* User */
15 NS_USER_TALK => "利用者‐会話", /* User_talk */
16 NS_PROJECT => $wgMetaNamespace, /* Wikipedia */
17 NS_PROJECT_TALK => "{$wgMetaNamespace}‐ノート", /* Wikipedia_talk */
18 NS_IMAGE => "画像", /* Image */
19 NS_IMAGE_TALK => "画像‐ノート", /* Image_talk */
20 NS_MEDIAWIKI => "MediaWiki", /* MediaWiki */
21 NS_MEDIAWIKI_TALK => "MediaWiki‐ノート", /* MediaWiki_talk */
22 NS_TEMPLATE => "Template", /* Template */
23 NS_TEMPLATE_TALK => "Template‐ノート", /* Template_talk */
24 NS_HELP => "Help", /* Help */
25 NS_HELP_TALK => "Help‐ノート", /* Help_talk */
26 NS_CATEGORY => "Category", /* Category */
27 NS_CATEGORY_TALK => "Category‐ノート" /* Category_talk */
28 ) + $wgNamespaceNamesEn;
29
30 /* private */ $wgQuickbarSettingsJa = array(
31 "なし", "左端", "右端", "ウィンドウの左上に固定"
32 );
33
34 /* private */ $wgSkinNamesJa = array(
35 'standard' => "標準",
36 'nostalgia' => "ノスタルジア",
37 'cologneblue' => "ケルンブルー",
38 ) + $wgSkinNamesEn;
39
40 /* private */ $wgDateFormatsJa = array(
41 MW_DATE_DEFAULT => '2001年1月15日 16:12 (デフォルト)',
42 MW_DATE_ISO => '2001-01-15 16:12:34'
43 );
44
45 /* private */ $wgWeekdayAbbreviationsJa = array(
46 "日", "月", "火", "水", "木", "金", "土"
47 );
48
49 if (!$wgCachedMessageArrays) {
50 require_once('MessagesJa.php');
51 }
52
53 class LanguageJa extends LanguageUtf8 {
54
55 function getNamespaces() {
56 global $wgNamespaceNamesJa;
57 return $wgNamespaceNamesJa;
58 }
59
60 function getQuickbarSettings() {
61 global $wgQuickbarSettingsJa;
62 return $wgQuickbarSettingsJa;
63 }
64
65 function getSkinNames() {
66 global $wgSkinNamesJa;
67 return $wgSkinNamesJa;
68 }
69
70 function getDateFormats() {
71 global $wgDateFormatsJa;
72 return $wgDateFormatsJa;
73 }
74
75 function date( $ts, $adj = false, $format = true, $tc = false ) {
76 global $wgWeekdayAbbreviationsJa;
77
78 if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); }
79 $datePreference = $this->dateFormat( $format );
80
81 if( $datePreference == MW_DATE_ISO ) {
82 $d = substr($ts, 0, 4). '-' . substr($ts, 4, 2). '-' .
83 substr($ts, 6, 2);
84 return $d;
85 }
86
87 $year = (int)substr( $ts, 0, 4 );
88 $month = (int)substr( $ts, 4, 2 );
89 $mday = (int)substr( $ts, 6, 2 );
90 $hour = (int)substr( $ts, 8, 2 );
91 $minute = (int)substr( $ts, 10, 2 );
92 $second = (int)substr( $ts, 12, 2 );
93
94 $time = mktime( $hour, $minute, $second, $month, $mday, $year );
95 $date = getdate( $time );
96
97 $d = $year . "年" .
98 $this->getMonthAbbreviation( $month ) .
99 $mday . "日 (" .
100 $wgWeekdayAbbreviationsJa[ $date['wday'] ]. ")";
101 return $d;
102 }
103
104 function time( $ts, $adj = false, $format = true, $tc = false ) {
105 if ( $adj ) { $ts = $this->userAdjust( $ts, $tc ); }
106 $datePreference = $this->dateFormat( $format );
107
108 $t = substr( $ts, 8, 2 ) . ":" . substr( $ts, 10, 2 );
109 if ( $datePreference == MW_DATE_ISO ) {
110 $t .= ':' . substr( $ts, 12, 2 );
111 }
112
113 return $t;
114 }
115
116 function timeanddate( $ts, $adj = false, $format = true, $tc = false ) {
117 return $this->date( $ts, $adj, $format, $tc ) . " " . $this->time( $ts, $adj, $format, $tc );
118 }
119
120 function getMessage( $key ) {
121 global $wgAllMessagesJa;
122 if(array_key_exists($key, $wgAllMessagesJa))
123 return $wgAllMessagesJa[$key];
124 else
125 return parent::getMessage($key);
126 }
127
128 function stripForSearch( $string ) {
129 # MySQL fulltext index doesn't grok utf-8, so we
130 # need to fold cases and convert to hex
131 global $wikiLowerChars;
132 $s = $string;
133
134 # Strip known punctuation ?
135 #$s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f
136
137 # Space strings of like hiragana/katakana/kanji
138 $hiragana = '(?:\xe3(?:\x81[\x80-\xbf]|\x82[\x80-\x9f]))'; # U3040-309f
139 $katakana = '(?:\xe3(?:\x82[\xa0-\xbf]|\x83[\x80-\xbf]))'; # U30a0-30ff
140 $kanji = '(?:\xe3[\x88-\xbf][\x80-\xbf]'
141 . '|[\xe4-\xe8][\x80-\xbf]{2}'
142 . '|\xe9[\x80-\xa5][\x80-\xbf]'
143 . '|\xe9\xa6[\x80-\x99])';
144 # U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99
145 $s = preg_replace( "/({$hiragana}+|{$katakana}+|{$kanji}+)/", ' $1 ', $s );
146
147 # Double-width roman characters: ff00-ff5f ~= 0020-007f
148 $s = preg_replace( '/\xef\xbc([\x80-\xbf])/e', 'chr((ord("$1") & 0x3f) + 0x20)', $s );
149 $s = preg_replace( '/\xef\xbd([\x80-\x99])/e', 'chr((ord("$1") & 0x3f) + 0x60)', $s );
150
151 # Do general case folding and UTF-8 armoring
152 return LanguageUtf8::stripForSearch( $s );
153 }
154
155 # Italic is not appropriate for Japanese script
156 # Unfortunately most browsers do not recognise this, and render <em> as italic
157 function emphasize( $text ) {
158 return $text;
159 }
160 }
161
162 ?>