Merged in feat/SW-1958-sort-languages (pull request #2540)

feat(SW-1958): add sorting of languge switcher languages

* feat(SW-1958): add sorting of languge switcher languages


Approved-by: Anton Gunnarsson
This commit is contained in:
Matilda Landström
2025-07-09 11:43:11 +00:00
parent 3615c48853
commit 2c0e8965e2

View File

@@ -16,8 +16,6 @@ import { replaceUrlPart } from "./utils"
import styles from "./languageSwitcherContent.module.css" import styles from "./languageSwitcherContent.module.css"
import type { Lang } from "@scandic-hotels/common/constants/language"
import type { LanguageSwitcherContentProps } from "@/types/components/languageSwitcher/languageSwitcher" import type { LanguageSwitcherContentProps } from "@/types/components/languageSwitcher/languageSwitcher"
export default function LanguageSwitcherContent({ export default function LanguageSwitcherContent({
@@ -27,7 +25,9 @@ export default function LanguageSwitcherContent({
const intl = useIntl() const intl = useIntl()
const currentLanguage = useLang() const currentLanguage = useLang()
const urlKeys = Object.keys(urls) as Lang[] const urlKeys = (Object.keys(urls) as (keyof typeof urls)[]).sort((a, b) => {
return languages[a].localeCompare(languages[b])
})
const pathname = usePathname() const pathname = usePathname()