Closed (outdated)
Project:
Drupal core
Version:
6.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jun 2008 at 15:20 UTC
Updated:
2 Mar 2016 at 22:18 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
damien tournoud commentedWell... no.
First we need to put as much as possible context in each translatable string. Just 'GB' is a too small string not to collide with other strings in different contexts (for what I know, it could mean Great Britain...), and to be correctly translatable to every language on the planet. We need to make sure that the full
"@size GB"is translated.Second, you should avoid using t() with a dynamically generated string, because it is harder for the extractor to get all possible combinations (it has to be hard coded in that case).
So:
selectwith redundant t()s in your code, but ok, that's not pretty)"@size " . $suffix(with no wildcard remplacement), and you provide a patch against potx for the strings to be extracted correctlyComment #2
kkaefer commentedThe way this worked before is that there was a special statement in the potx.module (which creates the translation templates) which adds the size prefixes to the source string pool. But I agree with Damien in that it’s better to provide context with such short abbreviations. I suggest using
return t('@size ' . $suffix, array('@size' => round($size, 2)), $langcode);and patching potx.module to include strings like ‘@size KB’, ‘@size MB’ and so on.Comment #3
damien tournoud commented@kkaefer#2: that's exacly my suggestion number 2 in #1 above, but thanks for agreeing.
I was thinking, is it possible that some languages would require to change the symbol depending on @size (ie. do we need to pass this thru
format_plural()) ?Comment #4
damien tournoud commentedHere is a solution to this problem. I chose to go the easiest way: remove the loop and treat units one by one. The resulting code is redundant, but is easily translatable and should be efficient.
All CommonFormatSizeTestCase tests pass before and after this patch.
Comment #5
mrharolda commentedYeah, that's probably a lot more efficient than the workaround I had laying over here:
and
return str_replace('@size', round($size, 2), $suffix);Comment #6
dries commentedI believe this needs to be backported to Drupal 6. Given that Gabor was closely involved with this code in the Drupal 6 development cycle, I'll let him do another review, and do the final commit. Thanks all! Changing the status and the version number.
Comment #7
gábor hojtsyWell, does not apply to 6.x since 6.x only supports KB and MB, it has no support for the bigger units. It has the '1 byte' and '@count bytes' quite right, but could use improvement with the KB and MB parts.
Either the suggested '@size KB', '@size MB' change should be ported to 6.x or the whole bigger size handling from 7.x. I am fine with either.
Comment #9
dpearcefl commentedIs this issue fixed in the latest D6? is there any interest in pursuing this issue?
Comment #10
dpearcefl commented