lang changes, new pages, data changes

This commit is contained in:
Henri
2026-02-12 05:27:53 +02:00
parent 1504844f0b
commit 9d13b57d2e
268 changed files with 3310 additions and 1541 deletions

View File

@@ -1,14 +1,43 @@
import { getTranslatedRoute, getLanguageFromRoute } from '../../routes';
import { switchLang } from '../i18n.js';
/**
* Navigate to a path (internal or external)
* @param {string} path - The path or URL to navigate to
* @param {boolean} external - Whether this is an external link (default: false)
* @param {Object} options - Navigation options
* @param {boolean} options.external - Whether this is an external link
*/
export function navigate(path, external = false) {
export function navigate(path, options = {}) {
const { external = false } = options;
if (external) {
window.location.href = path;
} else {
window.history.pushState({}, "", path);
window.dispatchEvent(new PopStateEvent('popstate'));
// Update language based on new route
const lang = getLanguageFromRoute(path);
if (lang) {
switchLang(lang);
}
}
}
/**
* Switch language and navigate to translated route
* @param {string} targetLang - Target language ('est' or 'en')
*/
export function switchLanguageRoute(targetLang) {
const currentPath = window.location.pathname;
const translatedPath = getTranslatedRoute(currentPath, targetLang);
// Always update the language first
switchLang(targetLang);
// Only navigate if the path is different
if (translatedPath !== currentPath) {
navigate(translatedPath);
}
}