add declension of words
This commit is contained in:
@@ -5,6 +5,7 @@ import { useQuery } from '@tanstack/react-query';
|
||||
import { getUserFilesInfo } from '@/app/actions/action';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { convertBytes } from '@/app/lib/convertBytes';
|
||||
import { pluralize } from '@/app/lib/pluralize';
|
||||
|
||||
export default function MyContentInfoBlock() {
|
||||
const t = useTranslations('Global');
|
||||
@@ -67,6 +68,11 @@ export default function MyContentInfoBlock() {
|
||||
return result;
|
||||
};
|
||||
|
||||
const pluralizeFiles = (number: number) => {
|
||||
const translate = [t('file'), t('files-few'), t('files')];
|
||||
return pluralize(number, translate[0], translate[1], translate[2]);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="block-wrapper auto grow">
|
||||
<div className="file-stats-container">
|
||||
@@ -83,7 +89,7 @@ export default function MyContentInfoBlock() {
|
||||
</div>
|
||||
<div className="file-stat-details">
|
||||
<span className="file-stat-count">
|
||||
{filesInfo.images_quantity ? filesInfo.images_quantity : 0} {t('files')}
|
||||
{filesInfo.images_quantity || 0} {pluralizeFiles(filesInfo.images_quantity || 0)}
|
||||
</span>
|
||||
<span className="file-stat-size">
|
||||
{filesInfo.images_size ? convertBytes(filesInfo.images_size) : 0}
|
||||
@@ -103,7 +109,7 @@ export default function MyContentInfoBlock() {
|
||||
</div>
|
||||
<div className="file-stat-details">
|
||||
<span className="file-stat-count">
|
||||
{filesInfo.videos_quantity ? filesInfo.videos_quantity : 0} {t('files')}
|
||||
{filesInfo.videos_quantity || 0} {pluralizeFiles(filesInfo.videos_quantity || 0)}
|
||||
</span>
|
||||
<span className="file-stat-size">
|
||||
{filesInfo.videos_size ? convertBytes(filesInfo.videos_size) : 0}
|
||||
@@ -123,7 +129,7 @@ export default function MyContentInfoBlock() {
|
||||
</div>
|
||||
<div className="file-stat-details">
|
||||
<span className="file-stat-count">
|
||||
{filesInfo.audios_quantity ? filesInfo.audios_quantity : 0} {t('files')}
|
||||
{filesInfo.audios_quantity || 0} {pluralizeFiles(filesInfo.audios_quantity || 0)}
|
||||
</span>
|
||||
<span className="file-stat-size">
|
||||
{filesInfo.audios_size ? convertBytes(filesInfo.audios_size) : 0}
|
||||
@@ -143,7 +149,7 @@ export default function MyContentInfoBlock() {
|
||||
</div>
|
||||
<div className="file-stat-details">
|
||||
<span className="file-stat-count">
|
||||
{filesInfo.documents_quantity ? filesInfo.documents_quantity : 0} {t('files')}
|
||||
{filesInfo.documents_quantity || 0} {pluralizeFiles(filesInfo.documents_quantity || 0)}
|
||||
</span>
|
||||
<span className="file-stat-size">
|
||||
{filesInfo.documents_size ? convertBytes(filesInfo.documents_size) : 0}
|
||||
|
||||
@@ -81,7 +81,7 @@ export default function MyContentPieChart() {
|
||||
useEffect(() => {
|
||||
setFilesCount([
|
||||
{
|
||||
name: 'images',
|
||||
name: 'images-few',
|
||||
value: filesInfo?.imageSize ? filesInfo?.imageSize : 0,
|
||||
color: '#f08c00'
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user