Skip to content

Conversation

@saschaszott
Copy link
Contributor

@saschaszott saschaszott commented Jan 29, 2026

Fixes #5054 .


transform(bytes: number = 0, precision: number = 2): string {
return filesize(bytes, { standard: 'jedec', round: precision });
return fileSize(bytes, {
Copy link
Contributor

@MMilosz MMilosz Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should stay with JEDEC (e.g., 1 MB = 1024 KB) or SI (e.g., 1 MB = 1000 KB). Even though I'm personally all for JEDEC, I believe most people in the world are familiar with the SI and expect SI units

Or maybe it should be moved to the configuration, so users could decide by themselves?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MMilosz , could you please create a new issue for this aspect.

@saschaszott saschaszott changed the base branch from main to dspace-8_x January 29, 2026 18:26
@tdonohue
Copy link
Member

@saschaszott : This PR looks to be invalid, as it contains a large number of unrelated commits. Did you maybe submit this to the wrong branch? (I see the branch you are submitting against is set to dspace-8_x. Maybe it should be main?)

@saschaszott saschaszott changed the base branch from dspace-8_x to main January 30, 2026 07:08
@saschaszott
Copy link
Contributor Author

@tdonohue , I originally implemented the extension of the FileSizePipe for DSpace CRIS 2024.02.03, which is based on DSpace 8.2. It took a few iterations to make it work with DSpace 10 as well. It should be working now. If we want to backport this change to older DSpace versions, the code will need to be adapted.

@saschaszott
Copy link
Contributor Author

I unfortunately have to pause at this point, as I currently don’t have a DSpace 10 development instance available. There seems to be an issue with the dependency injection of LocaleService into the FileSizePipe. Perhaps someone else can help? Alternatively, I can create a new PR to integrate this functionality into DSpace 8.

@tdonohue tdonohue added i18n / l10n Internationalisation and localisation, related to message catalogs 1 APPROVAL pull request only requires a single approval to merge labels Jan 30, 2026
@tdonohue tdonohue moved this to 🙋 Needs Reviewers Assigned in DSpace 10.0 Release Jan 30, 2026
@saschaszott
Copy link
Contributor Author

I have now set up a local DSpace Angular 10 test instance and applied the change there. In Chrome, I don’t see any error messages, and the desired result (localized display of the file size) is also visible. Therefore, the build error must have other causes.

@saschaszott
Copy link
Contributor Author

saschaszott commented Jan 30, 2026

I think I have found the cause: the LocaleService (or a mock of it) needs to be provided as a provider in the spec tests.

@saschaszott
Copy link
Contributor Author

@tdonohue , the PR is now finished; all spec tests are passing again. Should I create a new PR with one or two commits containing all changes, or will you squash all commits when merging?

Also, there is currently a general issue with running the E2E tests on GitHub (see my question on Slack).

@tdonohue
Copy link
Member

tdonohue commented Feb 2, 2026

@saschaszott : If you have a chance, I'd prefer you squash the commits yourself in this PR. This is possible to do by just doing a rebase on the branch this PR is based on (to squash the commits however you like) and do a "force push" to update the branch in this PR.

That preferable just because I sometimes forget to squash PRs when merging them.

@saschaszott
Copy link
Contributor Author

@tdonohue , this PR is ready for review!

@MMilosz
Copy link
Contributor

MMilosz commented Feb 3, 2026

I tested this locally and everything works fine. 👍 I checked various file sizes between 0B-1MB, locales (en, de, fr, fa).

English French
screenshot_20260203175541 screenshot_20260203175614
German & Persian screenshots

German (uses comma)

screenshot_20260203175640

Persian (uses momayyez, ٫)
screenshot_20260203180007

@tdonohue tdonohue moved this from 🙋 Needs Reviewers Assigned to 👍 Reviewer Approved in DSpace 10.0 Release Feb 3, 2026
@tdonohue tdonohue added this to the 10.0 milestone Feb 6, 2026
Copy link
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @saschaszott ! The code looks good and I also gave it a test. Works well. Because this is a tiny change and relates to i18n, I'm going to attempt to auto-backport this to 9.x as well.

@tdonohue tdonohue added the port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release label Feb 6, 2026
@tdonohue tdonohue merged commit 18726ef into DSpace:main Feb 6, 2026
16 checks passed
@github-project-automation github-project-automation bot moved this from 👍 Reviewer Approved to ✅ Done in DSpace 10.0 Release Feb 6, 2026
@dspace-bot
Copy link
Contributor

Backport failed for dspace-9_x, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin dspace-9_x
git worktree add -d .worktree/backport-5055-to-dspace-9_x origin/dspace-9_x
cd .worktree/backport-5055-to-dspace-9_x
git switch --create backport-5055-to-dspace-9_x
git cherry-pick -x d6af4addca63e3c3620d04f0b1cdcf94865ecb52

@tdonohue
Copy link
Member

tdonohue commented Feb 6, 2026

The backport failed. If someone has an interest in backporting this to 9.x, I think we could consider this a "bug fix" to i18n.

(I wasn't planning to backport it further though because this area of the code is not quite the same in older releases)

@saschaszott
Copy link
Contributor Author

@tdonohue , I can create a backport of this PR for DSpace version 7–9. Should I open a new PR for that?

@tdonohue
Copy link
Member

tdonohue commented Feb 9, 2026

@saschaszott : Yes, please open a new PR for backporting this to earlier versions. At a minimum, it'd be nice to backport this to 9.x. But, if we can backport it further, that's fine with me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge i18n / l10n Internationalisation and localisation, related to message catalogs port to dspace-9_x This PR needs to be ported to `dspace-9_x` branch for next bug-fix release

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

FileSizePipe does not respect locale settings

4 participants