r50778 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50777‎ | r50778 | r50779 >
Date:16:38, 19 May 2009
Author:shinjiman
Status:ok (Comments)
Tags:
Comment:
added Minguo calendar support for the Taiwan Chinese language
Modified paths:
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesZh_tw.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/messages/MessagesZh_tw.php
@@ -38,6 +38,29 @@
3939 NS_CATEGORY_TALK => '分類討論'
4040 );
4141
 42+$datePreferences = array(
 43+ 'default',
 44+ 'minguo',
 45+ 'CNS 7648',
 46+ 'ISO 8601',
 47+);
 48+
 49+$defaultDateFormat = 'zh';
 50+
 51+$dateFormats = array(
 52+ 'zh time' => 'H:i',
 53+ 'zh date' => 'Y年n月j日 (l)',
 54+ 'zh both' => 'Y年n月j日 (D) H:i',
 55+
 56+ 'minguo time' => 'H:i',
 57+ 'minguo date' => 'xoY年n月j日 (l)',
 58+ 'minguo both' => 'xoY年n月j日 (D) H:i',
 59+
 60+ 'CNS 7648 time' => 'H:i',
 61+ 'CNS 7648 date' => 'R.O.C. xoY-m-d (l)',
 62+ 'CNS 7648 both' => 'R.O.C. xoY-m-d (D) H:i',
 63+);
 64+
4265 $messages = array(
4366 # User preference toggles
4467 'tog-underline' => '鏈結標注底線',
Index: trunk/phase3/languages/Language.php
@@ -567,6 +567,8 @@
568568 *
569569 * xkY Y (full year) in Thai solar calendar. Months and days are
570570 * identical to the Gregorian calendar
 571+ * xoY Y (full year) in Minguo calendar. Months and days are
 572+ * identical to the Gregorian calendar
571573 *
572574 * Characters enclosed in double quotes will be considered literal (with
573575 * the quotes themselves removed). Unmatched quotes will be considered
@@ -598,6 +600,7 @@
599601 $hebrew = false;
600602 $hijri = false;
601603 $thai = false;
 604+ $minguo = false;
602605 for ( $p = 0; $p < strlen( $format ); $p++ ) {
603606 $num = false;
604607 $code = $format[$p];
@@ -605,7 +608,7 @@
606609 $code .= $format[++$p];
607610 }
608611
609 - if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' ) && $p < strlen( $format ) - 1 ) {
 612+ if ( ( $code === 'xi' || $code == 'xj' || $code == 'xk' || $code == 'xm' || $code == 'xo' ) && $p < strlen( $format ) - 1 ) {
610613 $code .= $format[++$p];
611614 }
612615
@@ -752,6 +755,10 @@
753756 if ( !$thai ) $thai = self::tsToThai( $ts );
754757 $num = $thai[0];
755758 break;
 759+ case 'xoY':
 760+ if ( !$minguo ) $minguo = self::tsToMinguo( $ts );
 761+ $num = $minguo[0];
 762+ break;
756763 case 'y':
757764 $num = substr( $ts, 2, 2 );
758765 break;
@@ -1132,7 +1139,26 @@
11331140 return array( $gy_thai, $gm, $gd );
11341141 }
11351142
 1143+ /**
 1144+ * Algorithm to convert Gregorian dates to Minguo dates.
 1145+ *
 1146+ * Link: http://en.wikipedia.org/wiki/Minguo_calendar
 1147+ *
 1148+ * @param $ts String: 14-character timestamp
 1149+ * @return array converted year, month, day
 1150+ */
 1151+ private static function tsToMinguo( $ts ) {
 1152+ $gy = substr( $ts, 0, 4 );
 1153+ $gm = substr( $ts, 4, 2 );
 1154+ $gd = substr( $ts, 6, 2 );
11361155
 1156+ # Deduct 1911 years from the Gregorian calendar
 1157+ # Months and days are identical
 1158+ $gy_minguo = $gy - 1911;
 1159+
 1160+ return array( $gy_minguo, $gm, $gd );
 1161+ }
 1162+
11371163 /**
11381164 * Roman number formatting up to 3000
11391165 */

Follow-up revisions

RevisionCommit summaryAuthorDate
r50781follow up r50778, updating the release notes.shinjiman17:02, 19 May 2009
r50807additional date format for Taiwan Chinese language, per code review on r50778.shinjiman03:02, 20 May 2009
r50808* (bug 18849) follow up r50778 and r50804, additional date format for Taiwan ...shinjiman03:29, 20 May 2009

Comments

#Comment by Jidanni (talk | contribs)   23:38, 19 May 2009

Currently you offer: 90年1月15日 (一) 16:12 R.O.C. 90-01-15 (一) 16:12 2001-01-15T16:12:34

Please add three choices: 民國..年 中華民國..年 ROC (more compact)

#Comment by Jidanni (talk | contribs)   23:39, 19 May 2009

Allow me to type that again

Currently you offer:

  1. 90年1月15日 (一) 16:12
  2. R.O.C. 90-01-15 (一) 16:12
  3. 2001-01-15T16:12:34

Please add three choices:

  1. 民國..年
  2. 中華民國..年
  3. ROC (more compact)
#Comment by Shinjiman (talk | contribs)   03:04, 20 May 2009

Added in r50807.

Status & tagging log