chore: full i8n support

This commit is contained in:
Chesterkxng committed 2026-07-16 17:23:56 +02:00
1 parent 0f411681fd
commit 66bd0afcff
2 files changed
+33 -21

No files matched your search

+15 -1
View File
@@ -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.",
+18 -20
View File
@@ -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<InitialValuesType>[] = [
];
export default function JsonToXml({ title }: ToolComponentProps) {
const { t } = useTranslation('json');
const [input, setInput] = useState<string>('');
const [result, setResult] = useState<string>('');
@@ -85,14 +83,18 @@ export default function JsonToXml({ title }: ToolComponentProps) {
exampleCards={exampleCards}
inputComponent={
<ToolCodeInput
title="Input Json"
title={t('jsonToXml.inputTitle')}
value={input}
onChange={setInput}
language="json"
/>
}
resultComponent={
<ToolTextResult title="Output XML" value={result} extension={'xml'} />
<ToolTextResult
title={t('jsonToXml.outputTitle')}
value={result}
extension={'xml'}
/>
}
getGroups={({ values, updateField }) => [
{
@@ -101,38 +103,34 @@ export default function JsonToXml({ title }: ToolComponentProps) {
<Box>
<SimpleRadio
checked={values.indentationType === 'space'}
title={'Use Spaces for indentation'}
description={
'Use spaces to visualize the hierarchical structure of XML.'
}
title={t('jsonToXml.options.useSpaceTitle')}
description={t('jsonToXml.options.useSpaceDesc')}
onClick={() => updateField('indentationType', 'space')}
/>
<SimpleRadio
checked={values.indentationType === 'tab'}
title={'Use Tabs for indentation'}
description={
'Use tabs to visualize the hierarchical structure of XML.'
}
title={t('jsonToXml.options.useTabTitle')}
description={t('jsonToXml.options.useTabDesc')}
onClick={() => updateField('indentationType', 'tab')}
/>
<SimpleRadio
checked={values.indentationType === 'none'}
title={'No indentation'}
description={'Output XML without any indentation.'}
title={t('jsonToXml.options.noIdentTitle')}
description={t('jsonToXml.options.noIdentDesc')}
onClick={() => updateField('indentationType', 'none')}
/>
</Box>
)
},
{
title: 'XML Meta Information',
title: t('jsonToXml.options.metaInfoTitle'),
component: (
<Box>
<CheckboxWithDesc
checked={values.addMetaTag}
onChange={(value) => 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')}
/>
</Box>
)