diff --git a/website/src/layouts/Layout.astro b/website/src/layouts/Layout.astro index 3f467dc..5e37a6c 100644 --- a/website/src/layouts/Layout.astro +++ b/website/src/layouts/Layout.astro @@ -4,15 +4,49 @@ interface Props { description?: string; } +const currentPath = Astro.url.pathname; +const isRussian = currentPath === '/ru/' || currentPath.startsWith('/ru/'); +const locale = isRussian ? 'ru' : 'en'; + const { title, - description = 'Voice Inbox turns accumulated voice recordings into a local Markdown or text inbox.', + description = isRussian + ? 'Voice Inbox превращает накопленные голосовые записи в локальные Markdown- или текстовые заметки.' + : 'Voice Inbox turns accumulated voice recordings into a local Markdown or text inbox.', } = Astro.props; const base = import.meta.env.BASE_URL.replace(/\/$/, ''); +const site = Astro.site?.toString().replace(/\/$/, '') ?? 'https://voiceinbox.simpleditor.org'; const gaId = import.meta.env.PUBLIC_GA_ID; const githubUrl = 'https://github.com/maxistar/Voice-Inbox'; const releaseUrl = `${githubUrl}/releases`; -const nav = [ + +const trimTrailingSlash = (path: string) => path.length > 1 ? path.replace(/\/$/, '') : path; +const toEnglishPath = (path: string) => { + if (path === '/ru' || path === '/ru/') return '/'; + if (path.startsWith('/ru/')) return path.replace('/ru', ''); + return path; +}; +const toRussianPath = (path: string) => { + if (path === '/') return '/ru/'; + if (path === '/ru' || path.startsWith('/ru/')) return path.endsWith('/') ? path : `${path}/`; + return `/ru${path}`; +}; +const englishPath = toEnglishPath(currentPath); +const russianPath = toRussianPath(currentPath); +const localized = (path: string) => isRussian ? toRussianPath(path) : path; +const withBase = (path: string) => `${base}${path}`; +const absolute = (path: string) => `${site}${path}`; + +const nav = isRussian ? [ + ['Главная', '/'], + ['О проекте', '/about/'], + ['Скачать', '/download/'], + ['Документация', '/docs/'], + ['Настройка', '/setup/'], + ['Тестирование', '/testing/'], + ['FAQ', '/faq/'], + ['Другие проекты', '/projects/'], +] : [ ['Home', '/'], ['About', '/about/'], ['Download', '/download/'], @@ -22,13 +56,22 @@ const nav = [ ['FAQ', '/faq/'], ['Other Projects', '/projects/'], ]; +const footerText = isRussian + ? 'Voice Inbox — локальная расшифровка голосовых заметок.' + : 'Voice Inbox - local-first voice note transcription.'; +const footerLabels = isRussian + ? { releases: 'Релизы', contact: 'Контакты', setup: 'Настройка', faq: 'FAQ', privacy: 'Приватность', legal: 'Правовая информация', source: 'Исходный код Voice Inbox на GitHub', language: 'Язык', nav: 'Основная навигация' } + : { releases: 'Releases', contact: 'Contact', setup: 'Setup', faq: 'FAQ', privacy: 'Privacy', legal: 'Legal', source: 'Voice Inbox source code on GitHub', language: 'Language', nav: 'Main navigation' }; --- - + + + + {title} - Voice Inbox { gaId && ( @@ -117,15 +160,26 @@ const nav = [ flex-wrap: wrap; gap: 12px 16px; } - nav a { + nav a, .language-switcher a { color: var(--muted); font-size: 0.88rem; font-weight: 650; } - nav a:hover { + nav a:hover, .language-switcher a:hover { color: var(--ink); text-decoration: none; } + .language-switcher { + display: inline-flex; + align-items: center; + gap: 8px; + border-left: 1px solid var(--border); + padding-left: 14px; + } + .language-switcher a[aria-current="true"] { + color: var(--ink); + font-weight: 850; + } main { flex: 1; width: 100%; @@ -277,6 +331,7 @@ const nav = [ flex-direction: column; } nav { justify-content: flex-start; } + .language-switcher { border-left: 0; padding-left: 0; } .page { padding-top: 38px; } } @@ -284,12 +339,17 @@ const nav = [
- -
@@ -300,16 +360,16 @@ const nav = [