Make WordPress Core

Opened 15 months ago

Closed 14 months ago

Last modified 13 months ago

#50194 closed enhancement (fixed)

Add i18n to size_format

Reported by: Rahe Owned by: audrasjb
Milestone: 5.5 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch commit
Focuses: Cc:



The units of the size_format function aren't translatable.
They are already translated on the network settings pages for the size of the upload folder or the size of the uploadable files.


Change History (12)

This ticket was mentioned in PR #275 on WordPress/wordpress-develop by Rahe.

15 months ago

Change the size_format and wp_convert_bytes_to_hr to add translatable strings for the units

Trac ticket: https://core.trac.wordpress.org/ticket/50194

#2 @audrasjb
15 months ago

  • Keywords has-patch added


This change makes sense to me.
I’d just suggest to add an additional translator comment when the file size is null, as the translation may be different for some locales in this specific case.

Maybe something like /* translators: File size in bytes, when the file size is null. */ ?

#3 @audrasjb
15 months ago

  • Milestone changed from Awaiting Review to 5.5

Let's move this ticket to milestone 5.5.

#4 @Rahe
15 months ago

Pull request updated

#5 @prbot
15 months ago

Rahe commented on PR #275:

Thank you for the review, everything is modified according to the comments

#6 @Rahe
15 months ago

PR updated :)

#7 @Rahe
15 months ago

Deprecated wp_convert_bytes_to_hr function restored to it's original state :)

#8 @audrasjb
14 months ago

  • Keywords commit added
  • Owner set to audrasjb
  • Status changed from new to accepted

Patch looks good to go, marking this for commit.

#9 @whyisjake
14 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 48054:

I18N: Add i18n to size_format().

Add translatable strings to the units of the size_format() function.

Props Rahe, audrasjb, ocean90.

Fixes #50194.

#11 @johnbillion
14 months ago

We could go a step further here and implement _nx() with a placeholder for the numeric value instead of always appending the unit to the end.

Question: Are there actually any languages where the unit for the size of a value differs depending on the plurality of the number? (eg. is KB/KBS a thing?) I don't know, maybe this would be an unnecessary change.

#12 @Rahe
13 months ago


I think that unit symbols are not sensitive to plural, we say 10 milliseconds and write 10ms, or 10 meters but write 10m.

According to this answer https://physics.stackexchange.com/a/384189

"Symbols for units are always written in roman (upright) type, irrespective of the type used in the rest of the text. The unit symbol shall remain unaltered in the plural and is not followed by a full stop except for normal punctuation, e.g. at the end of a sentence."

Note: See TracTickets for help on using tickets.