Scripting: Normalize output of FormatBytes#947
Merged
d0k3 merged 2 commits intod0k3:masterfrom Mar 18, 2026
Merged
Conversation
Wolfvak
approved these changes
Feb 16, 2026
Contributor
Author
|
The lua flag I mentioned in the OP has now been added (thanks @ihaveamac for actually doing the code). lua tested using this script, seems good: local stat = fs.stat_fs("0:")
print("Default:", ui.format_bytes(stat["free"]))
print("Explicit Normalized:", ui.format_bytes(stat["free"], {use_locale=false}))
print("Localized:", ui.format_bytes(stat["free"], {use_locale=true}))
ui.echo("Press A to exit.")
Edit: And (as seen in line 2) the lua API is unbroken from the previous version |
Wolfvak
reviewed
Feb 18, 2026
Wolfvak
approved these changes
Feb 18, 2026
Contributor
|
Since this technically changes the Lua behavior this should include an update to the documentation for ui.format_bytes. |
Contributor
|
Co-Authored-By: ihaveahax <ian@ianburgwin.net>
5611a25 to
d8f149c
Compare
Contributor
Author
|
Oh didn't see your second comment so I just wrote it myself 😅 Fixed the stray |
Contributor
|
It’s fine, yours is better than what I typed up anyway. |
Collaborator
|
about keeping it clean: we can just squash and merge, it's not a big deal |
Owner
|
Squashed and merged, thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The output of
FormatBytes()is localized, but it is provided to scripts and some (such as the hacks.guide finalizing script) expect it in the English format. Currently trying to run finalize with any locale that uses,as the decimal separator crashes the script and anything that renames "GB" (ex. French "Go") would cause that script to incorrectly display the no free space error if those languages didn't all use "," separator.I considered making the Lua version have a flag to enable/disable localization, but I couldn't quite tell what the proper way to do that would be.