import {createNavigation} from 'next-intl/navigation'
import {defineRouting} from 'next-intl/routing'

import {i18n} from '@/i18n-config'

export const locales = i18n.locales.map(locale => locale.code)

export const routing = defineRouting({
	locales,
	defaultLocale: i18n.defaultLocale,
	localePrefix: 'as-needed',
	localeCookie: {
		// Expire in one year
		maxAge: 60 * 60 * 24 * 365
	}
	/* pathnames: {
	// If all locales use the same pathname, a single
	// external path can be used for all locales
	} */
})

export const {Link, redirect, usePathname, useRouter, getPathname} =
	createNavigation(routing)
