resolveLocaleIndex #

Finds the locale key a route path belongs to. root owns every path outside the other locale prefixes; the longest matching prefix wins.

Usage #

TypeScript
import { 
resolveLocaleIndex
} from 'kawapress'
const
key
=
resolveLocaleIndex
('/en/guide', ['root', 'en'])

Parameters

pathstring

The route path, for example /en/guide/start.

localeKeysIterable<string>

The keys of the site's locales.

Returns The locale key, root when no prefix matches.

Full type signature
TypeScript
function resolveLocaleIndex(path: string, localeKeys: Iterable<string>): string

Edit this page

Comments