fix: i18n

This commit is contained in:
Ibrahima G. Coulibaly
2025-07-15 18:30:02 +01:00
parent 5ba8955890
commit bf2668b963
12 changed files with 106 additions and 89 deletions

View File

@@ -14,7 +14,7 @@ import { IconifyIcon } from '@iconify/react';
import { pdfTools } from '../pages/tools/pdf';
import { xmlTools } from '../pages/tools/xml';
import { TFunction } from 'i18next';
import { I18nNamespaces } from '../i18n';
import { FullI18nKey, I18nNamespaces } from '../i18n';
const toolCategoriesOrder: ToolCategory[] = [
'image-generic',
@@ -47,95 +47,93 @@ export const tools: DefinedTool[] = [
];
const categoriesConfig: {
type: ToolCategory;
value: string;
title?: string;
title: FullI18nKey;
value: FullI18nKey;
icon: IconifyIcon | string;
}[] = [
{
type: 'string',
title: 'Text',
icon: 'solar:text-bold-duotone',
value:
'Tools for working with text convert text to images, find and replace text, split text into fragments, join text lines, repeat text, and much more.'
value: 'translation:categories.string.description',
title: 'translation:categories.string.title'
},
{
type: 'png',
icon: 'ph:file-png-thin',
value:
'Tools for working with PNG images convert PNGs to JPGs, create transparent PNGs, change PNG colors, crop, rotate, resize PNGs, and much more.'
value: 'translation:categories.png.description',
title: 'translation:categories.png.title'
},
{
type: 'number',
icon: 'lsicon:number-filled',
value:
'Tools for working with numbers generate number sequences, convert numbers to words and words to numbers, sort, round, factor numbers, and much more.'
value: 'translation:categories.number.description',
title: 'translation:categories.number.title'
},
{
type: 'gif',
icon: 'material-symbols-light:gif-rounded',
value:
'Tools for working with GIF animations create transparent GIFs, extract GIF frames, add text to GIF, crop, rotate, reverse GIFs, and much more.'
value: 'translation:categories.gif.description',
title: 'translation:categories.gif.title'
},
{
type: 'list',
icon: 'solar:list-bold-duotone',
value:
'Tools for working with lists sort, reverse, randomize lists, find unique and duplicate list items, change list item separators, and much more.'
value: 'translation:categories.list.description',
title: 'translation:categories.list.title'
},
{
type: 'json',
icon: 'lets-icons:json-light',
value:
'Tools for working with JSON data structures prettify and minify JSON objects, flatten JSON arrays, stringify JSON values, analyze data, and much more'
value: 'translation:categories.json.description',
title: 'translation:categories.json.title'
},
{
type: 'time',
icon: 'mdi:clock-time-five',
value:
'Tools for working with time and date calculate time differences, convert between time zones, format dates, generate date sequences, and much more.'
value: 'translation:categories.time.description',
title: 'translation:categories.time.title'
},
{
type: 'csv',
icon: 'material-symbols-light:csv-outline',
value:
'Tools for working with CSV files - convert CSV to different formats, manipulate CSV data, validate CSV structure, and process CSV files efficiently.'
value: 'translation:categories.csv.description',
title: 'translation:categories.csv.title'
},
{
type: 'video',
icon: 'lets-icons:video-light',
value:
'Tools for working with videos extract frames from videos, create GIFs from videos, convert videos to different formats, and much more.'
value: 'translation:categories.video.description',
title: 'translation:categories.video.title'
},
{
type: 'pdf',
icon: 'tabler:pdf',
value:
'Tools for working with PDF files - extract text from PDFs, convert PDFs to other formats, manipulate PDFs, and much more.'
value: 'translation:categories.pdf.description',
title: 'translation:categories.pdf.title'
},
{
type: 'time',
icon: 'fluent-mdl2:date-time',
value:
'Tools for working with time and date draw clocks and calendars, generate time and date sequences, calculate average time, convert between time zones, and much more.'
value: 'translation:categories.time.description',
title: 'translation:categories.time.title'
},
{
type: 'image-generic',
title: 'Image',
icon: 'material-symbols-light:image-outline-rounded',
value:
'Tools for working with pictures compress, resize, crop, convert to JPG, rotate, remove background and much more.'
value: 'translation:categories.image-generic.description',
title: 'translation:categories.image-generic.title'
},
{
type: 'audio',
icon: 'ic:twotone-audiotrack',
value:
'Tools for working with audio extract audio from video, adjusting audio speed, merging multiple audio files and much more.'
value: 'translation:categories.audio.description',
title: 'translation:categories.audio.title'
},
{
type: 'xml',
icon: 'mdi-light:xml',
value:
'Tools for working with XML data structures - viewer, beautifier, validator and much more'
value: 'translation:categories.xml.description',
title: 'translation:categories.xml.title'
}
];
// use for changelogs
@@ -162,7 +160,9 @@ export const filterTools = (
);
};
export const getToolsByCategory = (): {
export const getToolsByCategory = (
t: TFunction<I18nNamespaces[]>
): {
title: string;
rawTitle: string;
description: string;
@@ -179,9 +179,13 @@ export const getToolsByCategory = (): {
(config) => config.type === type
);
return {
rawTitle: categoryConfig?.title ?? capitalizeFirstLetter(type),
title: `${categoryConfig?.title ?? capitalizeFirstLetter(type)} Tools`,
description: categoryConfig?.value ?? '',
rawTitle: categoryConfig?.title
? t(categoryConfig.title)
: capitalizeFirstLetter(type),
title: categoryConfig?.title
? t(categoryConfig.title)
: `${capitalizeFirstLetter(type)} Tools`,
description: categoryConfig?.value ? t(categoryConfig.value) : '',
type,
icon: categoryConfig!.icon,
tools: tools ?? [],