• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / Other / Localized Routes

Localized Routes

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' }
];

Filed Under: Other

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved