Files
gpx.studio/website/src/lib/languages.ts

18 lines
508 B
TypeScript
Raw Normal View History

2024-07-02 10:07:54 +02:00
export const languages: Record<string, string> = {
2024-06-19 19:42:36 +02:00
'en': 'English',
2024-07-08 15:46:00 +02:00
};
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('/');
}