From 03f3c1d5e6464adb660f5aa4f2f9b7033ba336ce Mon Sep 17 00:00:00 2001 From: Alexander Bocken Date: Fri, 2 Jan 2026 18:52:06 +0100 Subject: [PATCH] feat: reset to selection page when switching language on category/tag pages When switching languages on specific category or tag pages, redirect to the selection page instead of trying to maintain the same category/tag, since category and tag names differ between languages. Icon pages continue to swap directly since icons are consistent across languages. --- src/lib/components/LanguageSelector.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/components/LanguageSelector.svelte b/src/lib/components/LanguageSelector.svelte index 0126e00c..a9745081 100644 --- a/src/lib/components/LanguageSelector.svelte +++ b/src/lib/components/LanguageSelector.svelte @@ -63,7 +63,13 @@ // Convert current path to target language (for non-recipe pages) let newPath = path; - if (lang === 'en' && path.startsWith('/rezepte')) { + + // Special handling for category and tag pages - reset to selection page + // Icons are consistent across languages, so they can be swapped directly + if (path.match(/\/(rezepte|recipes)\/(category|tag)\//)) { + const pathType = path.match(/\/(category|tag)\//)?.[1]; + newPath = lang === 'en' ? `/recipes/${pathType}` : `/rezepte/${pathType}`; + } else if (lang === 'en' && path.startsWith('/rezepte')) { newPath = path.replace('/rezepte', '/recipes'); } else if (lang === 'de' && path.startsWith('/recipes')) { newPath = path.replace('/recipes', '/rezepte');