mirror of
https://github.com/nexu-io/openmotion.git
synced 2026-12-02 04:40:32 +08:00
8 lines
419 B
TypeScript
8 lines
419 B
TypeScript
/** Prism locale aliases shared by the catalog and local clients. */
|
|
export function catalogLocale(locales: string[], requested: string, fallback: string): string {
|
|
const normalize = (value: string) => value.toLowerCase() === 'zh' ? 'zh-cn' : value.toLowerCase();
|
|
return [requested, 'en', fallback]
|
|
.map(value => locales.find(locale => normalize(locale) === normalize(value)))
|
|
.find(Boolean) ?? fallback;
|
|
}
|