resolveLocaleIndex #

找出一个路由路径属于哪个语言的键。root 拥有其他语言前缀之外的所有路径;有多个前缀匹配时,取最长的。

用法 #

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

参数

pathstring

路由路径,例如 /en/guide/start。

localeKeysIterable<string>

站点 locales 的键。

返回值 语言的键;没有前缀匹配时是 root。

完整类型签名
TypeScript
function resolveLocaleIndex(path: string, localeKeys: Iterable<string>): string

编辑此页

评论