Info
- 6 posts
- 2 voices
- Started 2 years ago by taboo
- Latest reply from Sam Bauers
- This topic is not resolved
I18n problem in functions.bb-core.php
-
- Posted 2 years ago #
Hi,
I started investigating possibilities of translation bbPress to Polish. This language along with quite a few non-germanic languages has quite complex plural forms (3 forms instead of just 2). Not getting into much detail, because of the way functions.bb-core.php hardcodes seconds, hours, days... names it's hard to do a proper translation.
To do it right I'd need a function that uses "%d month" and not just "month" or "months" as defined here:
// array of time period chunks
$chunks = array(
array(60 * 60 * 24 * 365 , __('year') , __('years')),
array(60 * 60 * 24 * 30 , __('month') , __('months')),
array(60 * 60 * 24 * 7, __('week') , __('weeks')),
array(60 * 60 * 24 , __('day') , __('days')),
array(60 * 60 , __('hour') , __('hours')),
array(60 , __('minute') , __('minutes')),
array(1 , __('second') , __('seconds')),
);Any help would be very much appreciated.
-
- Posted 2 years ago #
I mean is there a way to separate months, seconds, etc. instead of just one output:
$print = sprintf(__('%1$d %2$s'), $count, (1 == $count) ? $name : $names);
-
- Posted 2 years ago #
Hmmm, that's lame. We should be using the plural translation functions there I think. I'll look into it.
-
- Posted 2 years ago #
Try replacing the function
bb_sincewith this and let me know if translation works better for you then:function bb_since( $original, $do_more = 0 ) { $today = time(); if ( !is_numeric($original) ) { if ( $today < $_original = bb_gmtstrtotime( str_replace(',', ' ', $original) ) ) // Looks like bb_since was called twice return $original; else $original = $_original; } // array of time period chunks $chunks = array( ( 60 * 60 * 24 * 365 ), // years ( 60 * 60 * 24 * 30 ), // months ( 60 * 60 * 24 * 7 ), // weeks ( 60 * 60 * 24 ), // days ( 60 * 60 ), // hours ( 60 ), // minutes ( 1 ) // seconds ); $since = $today - $original; for ($i = 0, $j = count($chunks); $i < $j; $i++) { $seconds = $chunks[$i]; if ( 0 != $count = floor($since / $seconds) ) break; } $trans = array( _n( '%d year', '%d years', $count ), _n( '%d month', '%d months', $count ), _n( '%d week', '%d weeks', $count ), _n( '%d day', '%d days', $count ), _n( '%d hour', '%d hours', $count ), _n( '%d minute', '%d minutes', $count ), _n( '%d second', '%d seconds', $count ) ); $print = sprintf( $trans[$i], $count ); if ( $do_more && $i + 1 < $j) { $seconds2 = $chunks[$i + 1]; if ( 0 != $count2 = floor( ($since - $seconds * $count) / $seconds2) ) $print .= sprintf( $trans[$i + 1], $count2 ); } return $print; } -
- Posted 2 years ago #
Yeah! That's it. Works great.
Thank you. Would you add this to 1.01 or whatever it's going to be called?
test drive: forum ginekologiczne
-
- Posted 2 years ago #
This was added to the 1.0.1 release that was just made.
-
You must log in to post.