gpx.studio/website/src/lib/languages.ts
2024-07-08 15:46:00 +02:00

18 lines
No EOL
508 B
TypeScript

export const languages: Record<string, string> = {
'en': 'English',
};
export function getURLForLanguage(lang?: string): string {
let currentPath = window.location.pathname;
let currentPathArray = currentPath.split('/');
if (currentPathArray.length > 1 && languages.hasOwnProperty(currentPathArray[1])) {
currentPathArray.splice(1, 1);
}
if (lang !== undefined && lang !== 'en') {
currentPathArray.splice(1, 0, lang);
}
return currentPathArray.join('/');
}