Skip to content
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

Added customSizes to fileupload component #13400

Closed

Conversation

SoyDiego
Copy link
Contributor

closes #13398

Added customSizes to personalize the units to display. This allow the internationalization
By default is: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'].

Example with french units: ['o', 'ko', 'Mo', 'Go', 'To', 'Po', 'Eo', 'Zo', 'Yo']

fileupload customsizes

Added documentation

image

@vercel
Copy link

vercel bot commented Jul 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
primeng-ssr-test ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2023 3:30pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
primeng ⬜️ Ignored (Inspect) Visit Preview Aug 29, 2023 3:30pm

Copy link

@ajjp ajjp left a comment

Choose a reason for hiding this comment

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

Thanks for the solution.

Just one remark: line 836 is missing the translation. I suggest this modification:

    const sizes = this.customSizes || ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
    if (bytes === 0) {
        return `0 ${sizes[0]}`;
    }

    const k = 1000;
    const dm = 3;

@SoyDiego
Copy link
Contributor Author

SoyDiego commented Aug 2, 2023

Thanks for the solution.

Just one remark: line 836 is missing the translation. I suggest this modification:

    const sizes = this.customSizes || ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
    if (bytes === 0) {
        return `0 ${sizes[0]}`;
    }

    const k = 1000;
    const dm = 3;

Thanks @ajjp,I forgot that part. Now I added :)

@mertsincan
Copy link
Member

Hi @SoyDiego,

I think you can add a locale option for it. https://github.com/primefaces/primelocale

en = {
...
   fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
}

fr = {
...
   fileSizeTypes: ['o', 'ko', 'Mo', 'Go', 'To', 'Po', 'Eo', 'Zo', 'Yo']
}

@SoyDiego
Copy link
Contributor Author

Hi @SoyDiego,

I think you can add a locale option for it. https://github.com/primefaces/primelocale

en = {
...
   fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
}

fr = {
...
   fileSizeTypes: ['o', 'ko', 'Mo', 'Go', 'To', 'Po', 'Eo', 'Zo', 'Yo']
}

Hi, that is new, right?

Hi @SoyDiego,

I think you can add a locale option for it. https://github.com/primefaces/primelocale

en = {
...
   fileSizeTypes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
}

fr = {
...
   fileSizeTypes: ['o', 'ko', 'Mo', 'Go', 'To', 'Po', 'Eo', 'Zo', 'Yo']
}

Hi, I don't think so because currently you assign that values and you cannot change.
With this PR you will.

image

But maybe this is another thing that you should talk as a team because in PrimeVue and PrimeReact you should implement too. It's a new feature and I don't know if you want this feature.

@mertsincan
Copy link
Member

Hi @SoyDiego,

Yes, it should be a new locale option. Please see our default locale options;
https://github.com/primefaces/primeng/blob/master/src/app/components/api/primengconfig.ts#L19

Users can automatically change the value of 'fileSizeTypes' by selecting any locale. I don't think there is a need for a separate FileUpload attribute for this.

Note: The change of 'dayNames' in Calendar according to locale can give you a clue. We would be grateful if you could send a PR to PrimeNg and others. I'll merge them ;)

Thanks a lot for your contribution! We really appreciate your PRs 🚀
Best Regards,

@SoyDiego
Copy link
Contributor Author

Ok, great, so we can close this PR if it's not necessary @mertsincan

@mertsincan
Copy link
Member

A new PR would be better ;) Thank you so much for your effort!

@SoyDiego
Copy link
Contributor Author

A new PR would be better ;) Thank you so much for your effort!

Ok great now I understood. I wrote you in private in Discord just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FileUpload: allow file size units internationalization
3 participants