feat: Armarium full customization and 4-language i18n (v0.8.0)
Replaces Astro Rocket demo content with Armarium branding and adds complete DE/FR/IT/EN translations across all pages. Branding & content (v0.7.0): - Add horizontal SVG logo to navbar with currentColor dark mode support - Rewrite homepage with Armarium hero, 6 feature cards, trust bar, Zürich coat of arms SVG, and CTA; shared HomePage.astro component - Add privacy page (/datenschutz) with 6 Infomaniak certification cards and 8-section policy (ISO 27001:2022, Swiss Hosting, nDSG/GDPR, etc.) - Add legal notice page (/impressum) - Rewrite about, contact, 404 pages with Armarium content - Add features page (/projects) from projects content collection - Add language switcher dropdown (LanguageSwitcherDropdown.astro) - Add single launch blog post; remove all demo blog/project content - Set up i18n foundation: astro.config.mjs, ui.ts, utils.ts Full i18n (v0.8.0): - Add all pages in FR/IT/EN: about, contact, blog, features, privacy, legal notice — 28 locale variants total - Language switcher visible in every layout (PageLayout, BlogLayout, ProjectLayout, LandingLayout) with translated nav items - Locale-aware nav and footer hrefs via nav.*.href keys in ui.ts - Shared page components (AboutPage, ContactPage, FeaturesIndexPage, BlogIndexPage) accept locale prop; locale pages are 4-line wrappers - Extend content.config.ts locale enum with de and it Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { ui, defaultLocale, type Locale } from './ui';
|
||||
|
||||
export function useTranslations(locale: Locale) {
|
||||
return function t(key: keyof typeof ui[typeof defaultLocale]): string {
|
||||
const localeUi = ui[locale] as Record<string, string>;
|
||||
const defaultUi = ui[defaultLocale] as Record<string, string>;
|
||||
return localeUi[key] ?? defaultUi[key] ?? key;
|
||||
};
|
||||
}
|
||||
|
||||
/** Returns the path for the given locale, stripping/adding the locale prefix. */
|
||||
export function getLocalePath(targetLocale: Locale, currentPath: string): string {
|
||||
const nonDefaultLocales: Locale[] = ['fr', 'it', 'en'];
|
||||
|
||||
let basePath = currentPath;
|
||||
for (const locale of nonDefaultLocales) {
|
||||
if (currentPath.startsWith(`/${locale}/`)) {
|
||||
basePath = currentPath.slice(locale.length + 1);
|
||||
break;
|
||||
} else if (currentPath === `/${locale}`) {
|
||||
basePath = '/';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (targetLocale === defaultLocale) return basePath || '/';
|
||||
return basePath === '/' ? `/${targetLocale}/` : `/${targetLocale}${basePath}`;
|
||||
}
|
||||
Reference in New Issue
Block a user