-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the String::humanize_size()
method
#31993
Improve the String::humanize_size()
method
#31993
Conversation
- Use "B" insted of "Bytes" to be more compact - Use suffixes that denote a binary prefix - Make suffixes localizable This removes the need for the custom `EditorNetworkProfiler:_format_bandwidth()` method.
0e7f97b
to
9a94fe7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
Any particular reason for using TTR and RTR? Are those meant to be localized? How?
@Faless Some languages use different unit suffixes. For instance, in French, we use "o", "Kio", "Mio", "Gio", … If I'm not mistaken, the As for the |
I see, weird...
This kinda breaks the idea of SI (which name is french BTW) and IEC, both
of which are supposed to be international.
But who am I to judge, let's merge :-)
…On Sat, Sep 7, 2019, 22:23 Hugo Locurcio ***@***.***> wrote:
@Faless <https://github.com/Faless> Some languages use different unit
suffixes. For instance, in French, we use "o", "Kio", "Mio", "Gio", …
As for the %s/s translation, I presume there are languages in which the
word for "second" doesn't start with a "s" 🙂
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#31993?email_source=notifications&email_token=AAM4C3XYIR342ORIPXYTZNTQIQETJA5CNFSM4IUAVLC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD6FBR7I#issuecomment-529144061>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAM4C3RXB5M2GX6TNBLCFZ3QIQETJANCNFSM4IUAVLCQ>
.
|
@@ -3296,7 +3296,7 @@ String String::humanize_size(size_t p_size) { | |||
int digits = prefix_idx > 0 ? _humanize_digits(p_size / _div) : 0; | |||
double divisor = prefix_idx > 0 ? _div : 1; | |||
|
|||
return String::num(p_size / divisor).pad_decimals(digits) + prefix[prefix_idx]; | |||
return String::num(p_size / divisor).pad_decimals(digits) + RTR(prefix[prefix_idx]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's bogus, RTR()
and TTR()
strings are extracted, not compiled, and there's no string to translate in prefix[prefix_idx]
. It's on the original strings themselves that you should use RTR
(and the leading space should likely be left out).
This removes the need for the custom
EditorNetworkProfiler:_format_bandwidth()
method, see discussion in #31870. We could also consider exposing this method to scripts, so that projects that need to display file sizes can use it directly.cc @Faless