Locale-aware EN/FR string dictionaries and the two-service data model (CVE Watch with per-locale URLs, Convert with a single URL).
12 lines
318 B
TypeScript
12 lines
318 B
TypeScript
export type Locale = 'en' | 'fr';
|
|
|
|
export const locales: Locale[] = ['en', 'fr'];
|
|
|
|
export function otherLocale(locale: Locale): Locale {
|
|
return locale === 'en' ? 'fr' : 'en';
|
|
}
|
|
|
|
export function swapLocalePath(pathname: string, from: Locale, to: Locale): string {
|
|
return pathname.replace(`/${from}/`, `/${to}/`);
|
|
}
|