This commit is contained in:
Ibrahima G. Coulibaly
2025-07-13 15:39:12 +01:00
parent 0ed18c7231
commit 24e0e38b4a
6 changed files with 43 additions and 80 deletions

View File

@@ -8,6 +8,8 @@ import { getToolsByCategory } from '@tools/index';
import { capitalizeFirstLetter } from '../utils/string';
import { IconifyIcon } from '@iconify/react';
import { useTranslation } from 'react-i18next';
import { ToolCategory } from '@tools/defineTool';
import { FullI18nKey } from '../i18n';
export default function ToolLayout({
children,
@@ -20,12 +22,12 @@ export default function ToolLayout({
title: string;
description: string;
icon?: IconifyIcon | string;
type: string;
type: ToolCategory;
children: ReactNode;
i18n?: {
name: string;
description: string;
shortDescription: string;
name: FullI18nKey;
description: FullI18nKey;
shortDescription: FullI18nKey;
};
}) {
const { t } = useTranslation();

View File

@@ -1,4 +1,4 @@
import i18n from 'i18next';
import i18n, { ParseKeys } from 'i18next';
import { initReactI18next } from 'react-i18next';
import enGlobal from './en.json';
import hiGlobal from './hi.json';
@@ -33,7 +33,7 @@ const locizeOptions = {
version: 'latest'
};
// Merge translations for demonstration; in a real app, use namespaces
const resources = {
export const resources = {
en: {
translation: enGlobal,
list: enList,
@@ -62,21 +62,18 @@ const resources = {
time: hiTime,
xml: hiXml
}
};
} as const;
i18n
// .use(Backend)
.use(initReactI18next)
.init({
resources,
lng: 'en',
fallbackLng: 'en',
interpolation: {
escapeValue: false
},
backend: locizeOptions,
saveMissing: true, // Send missing keys to Locize
updateMissing: true // Update keys in Locize
});
export type I18nNamespaces = keyof (typeof resources)['en'];
export type FullI18nKey = `${string}:${ParseKeys<I18nNamespaces>}`;
i18n.use(Backend).use(initReactI18next).init({
resources,
lng: 'en',
fallbackLng: 'en',
backend: locizeOptions,
saveMissing: true, // Send missing keys to Locize
updateMissing: true // Update keys in Locize
});
export default i18n;

View File

@@ -13,6 +13,9 @@
}
},
"changeSpeed": {
"title": "Change audio speed",
"description": "Change the playback speed of audio files. Speed up or slow down audio while maintaining pitch.",
"shortDescription": "Change the speed of audio files",
"newAudioSpeed": "New Audio Speed",
"speedDescription": "Default multiplier: 2 means 2x faster",
"outputFormat": "Output Format",

View File

@@ -1,6 +1,7 @@
import ToolLayout from '../components/ToolLayout';
import React, { JSXElementConstructor, LazyExoticComponent } from 'react';
import { IconifyIcon } from '@iconify/react';
import { FullI18nKey } from '../i18n';
export interface ToolMeta {
path: string;
@@ -12,10 +13,10 @@ export interface ToolMeta {
shortDescription: string;
longDescription?: string;
i18n?: {
name: string;
description: string;
shortDescription: string;
longDescription?: string;
name: FullI18nKey;
description: FullI18nKey;
shortDescription: FullI18nKey;
longDescription?: FullI18nKey;
};
}