Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2011-06-10 00:01:30
- Vinster
- New Member
- From: Montreal, Québec, Canada
- Registered: 2011-06-09
- Posts: 7
How to display file size in other language
Hi
I’m currently using the “<txp:file_download_size />” tag to display the size of my download files, but it writes “kb”, “mb”, etc. I’d like to display those in french which would be “ko”, “mo”, etc.
Is there a way to display the text in french ?
My textpattern is currently set to french as the default language
Thanks for you help!
PS: Oh and have a coma rather then a dot, and a space between the numbers and the letters. Where do you actually manage the formatting ?
Last edited by Vinster (2011-06-10 00:03:23)
Hope for the best, but prepare for the worst!
Offline
Re: How to display file size in other language
Vinster wrote:
it writes “kb”, “mb”, etc. I’d like to display those in french which would be “ko”, “mo”, etc.
Erm. Unfortunately those are currently hard-coded in the tag. Which is awful! I’ve just taken a look and there’s actually a rather embarrassing bug in that tag that (thankfully) nobody’s found yet, owing to the fact that nobody has ever uploaded a terabyte-size file. But that’s not the point!
I’m just trying out a more robust tag and, during the course of this fix, I’ll see if I can get it to display localised size tags. This will probably require some more language strings to be defined, but we can sort that out fairly easily.
a coma rather then a dot, and a space between the numbers and the letters
Hmmm, in theory this should be taken care of by PHP’s number_format()
function, which this tag uses. It should use the localised number system for your installation but I’ll test this as well to see if it works as expected.
EDIT: tag fixed on my local development site. It:
- fixes the terabyte bug
- is more efficient / shorter
- automatically takes care of the number formatting decimal / thousands separator depending on your locale
- displays the size identifiers as unit_B / K / M / G / T / P / E / Z / Y(!) which can all be made language strings in the database and thus will be displayed in the local language once the translators catch up
I’ve posted the code to the other devs for review. Hopefully it’ll be in time to sneak into TXP 4.4.1 but I’m not sure, as we’re already at RC1 for that release.
Last edited by Bloke (2011-06-10 16:20:54)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: How to display file size in other language
One way could be to use rah_replace to modify the output to your needs. At least could work as a temporary solution. For example, according what you said, something like:
<txp:rah_replace from="kb|mb|." to=" ko| mo|," delimiter="|">
<txp:file_download_size />
</txp:rah_replace>
Offline
Re: How to display file size in other language
Patch committed. Thanks Vinster. When the French translation is complete for the new uints_b / units_k / units_m, etc strings you’ll see the suffixes in your language. The thousands separator and decimal point will also adjust to the current locale.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
#5 2011-06-11 22:49:19
- Vinster
- New Member
- From: Montreal, Québec, Canada
- Registered: 2011-06-09
- Posts: 7
Re: How to display file size in other language
Wow, great work !
Many thanks to you Bloke.
@Gocom, nice I didn’tknow about the rah_replace tag. That should be of great use in some situations I’ll probably encounter.
Hope for the best, but prepare for the worst!
Offline