export const localizedRoutes: Record<string, Record<string, string>> = {
hu: {
home: '',
'cookie-policy': 'suti-szabalyzat',
'privacy-policy': 'adatvedelmi-szabalyzat'
},
en: {
home: '',
'cookie-policy': 'cookie-policy',
'privacy-policy': 'privacy-policy'
},
de: {
home: '',
'cookie-policy': 'cookie-richtlinie',
'privacy-policy': 'datenschutz'
}
};
app.routes.ts
import { Routes } from '@angular/router';
import { localizedRoutes } from './localized-routes';
export const generateLocalizedRoutes = (lang: string): Routes => {
const routesForLang = localizedRoutes[lang];
return [
{
path: routesForLang['home'],
loadComponent: () => import('./features/home/home.component').then((m) => m.HomeComponent),
data: {
title: 'TITLE.HOME'
}
},
{
path: routesForLang['cookie-policy'],
loadComponent: () =>
import('./features/cookie-policy/cookie-policy.component').then((m) => m.CookiePolicyComponent),
data: {
title: 'TITLE.COOKIE_POLICY'
}
},
{
path: routesForLang['privacy-policy'],
loadComponent: () =>
import('./features/privacy-policy/privacy-policy.component').then((m) => m.PrivacyPolicyComponent),
data: {
title: 'TITLE.PRIVACY_POLICY'
}
},
{
path: routesForLang['terms-and-conditions'],
loadComponent: () =>
import('./features/terms-and-conditions/terms-and-conditions.component').then(
(m) => m.TermsAndConditionsComponent
),
data: {
title: 'TITLE.TERMS_AND_CONDITIONS'
}
},
{
path: routesForLang['impressum'],
loadComponent: () => import('./features/impressum/impressum.component').then((m) => m.ImpressumComponent),
data: {
title: 'TITLE.IMPRESSUM'
}
},
{
path: routesForLang['404'],
loadComponent: () => import('./core/not-found/not-found.component').then((m) => m.NotFoundComponent),
data: {
title: 'TITLE.NOT_FOUND'
}
},
{
path: '**',
redirectTo: routesForLang['404']
}
];
};
const langs = ['hu', 'en', 'de'];
export const routes: Routes = [
...langs.map((lang) => ({
path: lang,
children: generateLocalizedRoutes(lang)
})),
{ path: '', redirectTo: 'hu', pathMatch: 'full' },
{ path: '**', redirectTo: 'hu/404' }
];