summaryrefslogtreecommitdiff
path: root/examples/docs/src/languages.ts
blob: ffc6809541e74f5766cf215075faa536daf4adef (plain) (blame)
1
2
3
4
5
6
7
8
9
10
import { KNOWN_LANGUAGES } from './config';

export { KNOWN_LANGUAGES };
export const KNOWN_LANGUAGE_CODES = Object.values(KNOWN_LANGUAGES);
export const langPathRegex = /\/([a-z]{2}-?[A-Z]{0,2})\//;

export function getLanguageFromURL(pathname: string) {
	const langCodeMatch = pathname.match(langPathRegex);
	return langCodeMatch ? langCodeMatch[1] : 'en';
}