diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 3daede278..5d70efc9c 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -1427,6 +1427,9 @@ "settings": { "title": "Settings" }, + "tooltip": { + "description": "Extracts the selected pages into a new PDF, preserving order." + }, "error": { "failed": "Failed to extract pages" }, @@ -1511,6 +1514,7 @@ } }, "bulkSelection": { + "syntaxError": "There is a syntax issue. See Page Selection tips for help.", "header": { "title": "Page Selection Guide" }, diff --git a/frontend/public/locales/en-US/translation.json b/frontend/public/locales/en-US/translation.json index b8c91ae14..f0b241bf9 100644 --- a/frontend/public/locales/en-US/translation.json +++ b/frontend/public/locales/en-US/translation.json @@ -902,6 +902,9 @@ "settings": { "title": "Settings" }, + "tooltip": { + "description": "Extracts the selected pages into a new PDF, preserving order." + }, "error": { "failed": "Failed to extract pages" }, @@ -975,6 +978,7 @@ } }, "bulkSelection": { + "syntaxError": "There is a syntax issue. See Page Selection tips for help.", "header": { "title": "Page Selection Guide" }, "syntax": { "title": "Syntax Basics", diff --git a/frontend/src/core/components/shared/PageSelectionSyntaxHint.tsx b/frontend/src/core/components/shared/PageSelectionSyntaxHint.tsx index ee92d7f18..bf7e64206 100644 --- a/frontend/src/core/components/shared/PageSelectionSyntaxHint.tsx +++ b/frontend/src/core/components/shared/PageSelectionSyntaxHint.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { useTranslation } from 'react-i18next'; import { Text } from '@mantine/core'; import classes from '@app/components/pageEditor/bulkSelectionPanel/BulkSelectionPanel.module.css'; import { parseSelectionWithDiagnostics } from '@app/utils/bulkselection/parseSelection'; @@ -15,6 +16,7 @@ const FALLBACK_MAX_PAGES = 100000; // large upper bound for syntax validation wi const PageSelectionSyntaxHint = ({ input, maxPages, variant = 'panel' }: PageSelectionSyntaxHintProps) => { const [syntaxError, setSyntaxError] = useState(null); + const { t } = useTranslation(); useEffect(() => { const text = (input || '').trim(); @@ -25,9 +27,9 @@ const PageSelectionSyntaxHint = ({ input, maxPages, variant = 'panel' }: PageSel try { const { warning } = parseSelectionWithDiagnostics(text, maxPages && maxPages > 0 ? maxPages : FALLBACK_MAX_PAGES); - setSyntaxError(warning ? 'There is a syntax issue. See Page Selection tips for help.' : null); + setSyntaxError(warning ? t('bulkSelection.syntaxError', 'There is a syntax issue. See Page Selection tips for help.') : null); } catch { - setSyntaxError('There is a syntax issue. See Page Selection tips for help.'); + setSyntaxError(t('bulkSelection.syntaxError', 'There is a syntax issue. See Page Selection tips for help.')); } }, [input, maxPages]); diff --git a/frontend/src/core/components/tooltips/useExtractPagesTips.ts b/frontend/src/core/components/tooltips/useExtractPagesTips.ts new file mode 100644 index 000000000..7c13b30c2 --- /dev/null +++ b/frontend/src/core/components/tooltips/useExtractPagesTips.ts @@ -0,0 +1,22 @@ +import { useTranslation } from 'react-i18next'; +import { TooltipContent } from '@app/types/tips'; +import { usePageSelectionTips } from '@app/components/tooltips/usePageSelectionTips'; + +export const useExtractPagesTips = (): TooltipContent => { + const { t } = useTranslation(); + const base = usePageSelectionTips(); + + return { + header: base.header, + tips: [ + { + description: t('extractPages.tooltip.description', 'Extracts the selected pages into a new PDF, preserving order.') + }, + ...(base.tips || []) + ] + }; +}; + +export default useExtractPagesTips; + + diff --git a/frontend/src/core/data/useTranslatedToolRegistry.tsx b/frontend/src/core/data/useTranslatedToolRegistry.tsx index a5c681cd6..fca3ab9b0 100644 --- a/frontend/src/core/data/useTranslatedToolRegistry.tsx +++ b/frontend/src/core/data/useTranslatedToolRegistry.tsx @@ -79,6 +79,7 @@ import { overlayPdfsOperationConfig } from "@app/hooks/tools/overlayPdfs/useOver import { adjustPageScaleOperationConfig } from "@app/hooks/tools/adjustPageScale/useAdjustPageScaleOperation"; import { scannerImageSplitOperationConfig } from "@app/hooks/tools/scannerImageSplit/useScannerImageSplitOperation"; import { addPageNumbersOperationConfig } from "@app/components/tools/addPageNumbers/useAddPageNumbersOperation"; +import { extractPagesOperationConfig } from "@app/hooks/tools/extractPages/useExtractPagesOperation"; import CompressSettings from "@app/components/tools/compress/CompressSettings"; import AddPasswordSettings from "@app/components/tools/addPassword/AddPasswordSettings"; import RemovePasswordSettings from "@app/components/tools/removePassword/RemovePasswordSettings"; @@ -108,7 +109,6 @@ import ExtractImages from "@app/tools/ExtractImages"; import ExtractPages from "@app/tools/ExtractPages"; import ExtractImagesSettings from "@app/components/tools/extractImages/ExtractImagesSettings"; import ExtractPagesSettings from "@app/components/tools/extractPages/ExtractPagesSettings"; -import { extractPagesOperationConfig } from "@app/hooks/tools/extractPages/useExtractPagesOperation"; import ReplaceColorSettings from "@app/components/tools/replaceColor/ReplaceColorSettings"; import AddStampAutomationSettings from "@app/components/tools/addStamp/AddStampAutomationSettings"; import CertSignAutomationSettings from "@app/components/tools/certSign/CertSignAutomationSettings"; diff --git a/frontend/src/core/hooks/tools/extractPages/useExtractPagesOperation.ts b/frontend/src/core/hooks/tools/extractPages/useExtractPagesOperation.ts index 634215260..086fd65cc 100644 --- a/frontend/src/core/hooks/tools/extractPages/useExtractPagesOperation.ts +++ b/frontend/src/core/hooks/tools/extractPages/useExtractPagesOperation.ts @@ -12,7 +12,7 @@ async function resolveSelectionToCsv(expression: string, file: File): Promise { const { t } = useTranslation(); + const tooltipContent = useExtractPagesTips(); const base = useBaseTool( 'extract-pages', @@ -35,6 +37,7 @@ const ExtractPages = (props: BaseToolProps) => { isCollapsed: base.settingsCollapsed, onCollapsedClick: base.settingsCollapsed ? base.handleSettingsReset : undefined, content: settingsContent, + tooltip: tooltipContent, }, ], executeButton: {