あくまでちょっと。
通常Twitter Stream上で表示されるつぶやきの投稿時間の表示は10 minute agoとか1 hour agoとか表示されるんだけども、日本語混じりのサイトでは何だかそこだけ浮きます。
そこで、投稿時間の表示だけ地味に日本語化しようと思います。
弄るのは358行目から3行くらいと365行目、379行目のみ。超簡単w
実際のコードはこんな感じ。
//Work out the time in the AGO tense. Thanks to http://css-tricks.com for this snippet…
function twitter_stream_time_ago($time)
{
$singular = array(__(“second”, ‘twit_stream’), __(“minute”, ‘twit_stream’), __(“hour”, ‘twit_stream’), __(“day”, ‘twit_stream’), __(“week”, ‘twit_stream’), __(“month”, ‘twit_stream’), __(“year”, ‘twit_stream’), __(“decade”, ‘twit_stream’));
$plural = array(__(“seconds”, ‘twit_stream’), __(“minutes”, ‘twit_stream’), __(“hours”, ‘twit_stream’), __(“days”, ‘twit_stream’), __(“weeks”, ‘twit_stream’), __(“months”, ‘twit_stream’), __(“years”, ‘twit_stream’), __(“decades”, ‘twit_stream’));
$lengths = array(“60″,”60″,”24″,”7″,”4.35″,”12″,”10”);$now = time();
$difference = $now – $time;
$tense = __(“ago”, ‘twit_stream’);for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}$difference = round($difference);
if($difference != 1) {
$period = $plural[$j];
} else {
$period = $singular[$j];
}return “{$difference} {$period} {$tense}”;
}
これをこんな感じに書き換えます。
358、359行目 時間の単位を日本語に。
365行目 agoを日本語に。
379行目 余分なスペースを削除。
//Work out the time in the AGO tense. Thanks to http://css-tricks.com for this snippet…
function twitter_stream_time_ago($time)
{
$singular = array(__(“秒”, ‘twit_stream’), __(“分”, ‘twit_stream’), __(“時間”, ‘twit_stream’), __(“日”, ‘twit_stream’), __(“週”, ‘twit_stream’), __(“月”, ‘twit_stream’), __(“年”, ‘twit_stream’), __(“decade”, ‘twit_stream’));
$plural = array(__(“秒”, ‘twit_stream’), __(“分”, ‘twit_stream’), __(“時間”, ‘twit_stream’), __(“日”, ‘twit_stream’), __(“週”, ‘twit_stream’), __(“月”, ‘twit_stream’), __(“年”, ‘twit_stream’), __(“decades”, ‘twit_stream’));
$lengths = array(“60″,”60″,”24″,”7″,”4.35″,”12″,”10”);$now = time();
$difference = $now – $time;
$tense = __(“前”, ‘twit_stream’);for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) {
$difference /= $lengths[$j];
}$difference = round($difference);
if($difference != 1) {
$period = $plural[$j];
} else {
$period = $singular[$j];
}return “{$difference}{$period}{$tense}”;
}
これでTwitter Streamが中途半端に日本語対応になりましたw
コメントは受け付けていません。