mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
11 lines
409 B
TypeScript
11 lines
409 B
TypeScript
import { KNOWN_LANGUAGES, KNOWN_LANGUAGE_CODES } from './config';
|
|
export { KNOWN_LANGUAGES, KNOWN_LANGUAGE_CODES };
|
|
|
|
export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;
|
|
|
|
export function getLanguageFromURL(pathname: string) {
|
|
const langCodeMatch = pathname.match(langPathRegex);
|
|
const langCode = langCodeMatch ? langCodeMatch[1] : 'en';
|
|
return langCode as (typeof KNOWN_LANGUAGE_CODES)[number];
|
|
}
|