From 414c05f7112d2b6e6194000a89a0f197778e6e3f Mon Sep 17 00:00:00 2001 From: Achim Rohn Date: Wed, 13 Aug 2025 11:11:59 +0200 Subject: [PATCH] Check active path for being the root path --- i18n.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/i18n.go b/i18n.go index 4795698..4fc8b65 100644 --- a/i18n.go +++ b/i18n.go @@ -9,6 +9,10 @@ const ( De Language = "de" ) +func (t Language) GetPath() string { + return "/" + string(t) +} + type GlobalI18nTexts interface { Add(text I18nText) GlobalI18nTexts GetAllTexts() []I18nText @@ -87,10 +91,13 @@ func NewActivePath(langMap map[Language]string, paths LanguagePaths) ActivePath } func (a ActivePath) GetPath(language Language) string { - return "/" + string(language) + a.Paths[language] + return language.GetPath() + a.Paths[language] } func (a ActivePath) IsActive(c HtmxContext) bool { pathWithLang := a.GetPath(c.GetLanguage()) + if pathWithLang == c.GetLanguage().GetPath()+"/" { + return pathWithLang == c.GetPath() + } return strings.HasPrefix(c.GetPath(), pathWithLang) }