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