From 66bd0afcff680fb50240027ac55ca71da5c522ee Mon Sep 17 00:00:00 2001 From: Chesterkxng Date: Thu, 16 Jul 2026 17:23:56 +0200 Subject: [PATCH] chore: full i8n support --- public/locales/en/json.json | 16 ++++++++- src/pages/tools/json/json-to-xml/index.tsx | 38 ++++++++++------------ 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/public/locales/en/json.json b/public/locales/en/json.json index f4df20c1..d84e24fc 100644 --- a/public/locales/en/json.json +++ b/public/locales/en/json.json @@ -37,7 +37,21 @@ "jsonToXml": { "description": "Convert JSON data to XML format. Transform structured JSON objects into well-formed XML documents.", "shortDescription": "Convert JSON to XML format", - "title": "JSON to XML" + "title": "JSON to XML", + "inputTitle": "Input JSON", + "outputTitle": "Output XML", + "options": { + "indentationTitle": "Indentation Options", + "useSpaceTitle": "Use Spaces for indentation", + "useSpaceDesc": "Use spaces to visualize the hierarchical structure of XML.", + "useTabTitle": "Use Tabs for indentation", + "useTabDesc": "Use tabs to visualize the hierarchical structure of XML.", + "noIdentTitle": "No indentation", + "noIdentDesc": "Output XML without any indentation.", + "metaInfoTitle": "XML Meta Information", + "addMetaTagTitle": "Add an XML Meta Tag", + "addMetaTagDesc": "Add a meta tag at the beginning of the XML output" + } }, "minify": { "description": "Remove all unnecessary whitespace from JSON.", diff --git a/src/pages/tools/json/json-to-xml/index.tsx b/src/pages/tools/json/json-to-xml/index.tsx index 5c20ee22..64b7eeff 100644 --- a/src/pages/tools/json/json-to-xml/index.tsx +++ b/src/pages/tools/json/json-to-xml/index.tsx @@ -8,11 +8,8 @@ import { ToolComponentProps } from '@tools/defineTool'; import { Box } from '@mui/material'; import CheckboxWithDesc from '@components/options/CheckboxWithDesc'; import SimpleRadio from '@components/options/SimpleRadio'; - -type InitialValuesType = { - indentationType: 'space' | 'tab' | 'none'; - addMetaTag: boolean; -}; +import { InitialValuesType } from './types'; +import { useTranslation } from 'react-i18next'; const initialValues: InitialValuesType = { indentationType: 'space', @@ -57,6 +54,7 @@ const exampleCards: CardExampleType[] = [ ]; export default function JsonToXml({ title }: ToolComponentProps) { + const { t } = useTranslation('json'); const [input, setInput] = useState(''); const [result, setResult] = useState(''); @@ -85,14 +83,18 @@ export default function JsonToXml({ title }: ToolComponentProps) { exampleCards={exampleCards} inputComponent={ } resultComponent={ - + } getGroups={({ values, updateField }) => [ { @@ -101,38 +103,34 @@ export default function JsonToXml({ title }: ToolComponentProps) { updateField('indentationType', 'space')} /> updateField('indentationType', 'tab')} /> updateField('indentationType', 'none')} /> ) }, { - title: 'XML Meta Information', + title: t('jsonToXml.options.metaInfoTitle'), component: ( updateField('addMetaTag', value)} - title="Add an XML Meta Tag" - description="Add a meta tag at the beginning of the XML output." + title={t('jsonToXml.options.addMetaTagTitle')} + description={t('jsonToXml.options.addMetaTagDesc')} /> )