Skip to:
Content

bbPress.org

Changeset 483


Ignore:
Timestamp:
10/16/2006 08:53:12 PM (20 years ago)
Author:
mdawaffe
Message:

Better i18n for bb_since(). Can't use ngettext(); too bad. Props SteveAgl. Fixes #442

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-includes/functions.php

    r482 r483  
    246246    // array of time period chunks
    247247    $chunks = array(
    248         array(60 * 60 * 24 * 365 , __('year')),
    249         array(60 * 60 * 24 * 30 , __('month')),
    250         array(60 * 60 * 24 * 7, __('week')),
    251         array(60 * 60 * 24 , __('day')),
    252         array(60 * 60 , __('hour')),
    253         array(60 , __('minute')),
     248        array(60 * 60 * 24 * 365 , __('year') , __('years')),
     249        array(60 * 60 * 24 * 30 , __('month') , __('months')),
     250        array(60 * 60 * 24 * 7, __('week') , __('weeks')),
     251        array(60 * 60 * 24 , __('day') , __('days')),
     252        array(60 * 60 , __('hour') , __('hours')),
     253        array(60 , __('minute') , __('minutes')),
    254254    );
    255255
    256256    $today = time();
    257257    $since = $today - bb_offset_time($original);
    258    
     258
    259259    for ($i = 0, $j = count($chunks); $i < $j; $i++) {
    260260        $seconds = $chunks[$i][0];
    261261        $name = $chunks[$i][1];
    262        
     262        $names = $chunks[$i][2];
     263
    263264        if (($count = floor($since / $seconds)) != 0)
    264265            break;
    265266    }
    266    
    267     $print = ($count == 1) ? '1 '.$name : "$count {$name}s";
    268    
     267
     268    $print = sprintf(__('%1$d %2$s'), $count, ($count == 1) ? $name : $names);
     269
    269270    if ($i + 1 < $j) {
    270271        $seconds2 = $chunks[$i + 1][0];
    271272        $name2 = $chunks[$i + 1][1];
    272        
     273        $names2 = $chunks[$i + 1][1];
     274
    273275        // add second item if it's greater than 0
    274276        if ( (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0) && $do_more )
    275             $print .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
     277            $print .= sprintf(__(', %1$d %2$s'), $count2, ($count2 == 1) ? $name2 : $names2);
    276278    }
    277279    return $print;
Note: See TracChangeset for help on using the changeset viewer.