Skip to content

Enhance FileSizePipe to support localization#5055

Open
saschaszott wants to merge 1 commit intoDSpace:mainfrom
saschaszott:saschaszott-patch-15
Open

Enhance FileSizePipe to support localization#5055
saschaszott wants to merge 1 commit intoDSpace:mainfrom
saschaszott:saschaszott-patch-15

Conversation

@saschaszott
Copy link
Contributor

This PR is related to / fixes issue #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
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

Projects

Status: 👍 Reviewer Approved

Development

Successfully merging this pull request may close these issues.

3 participants