Skip to content

Commit b294598

Browse files
committed
feat: Add translations
1 parent 82c007f commit b294598

44 files changed

Lines changed: 1391 additions & 278 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<ai_agent_rules>
2+
MANDATORY - Read before ANY task. Do NOT skip steps.
3+
4+
<load_documentation>
5+
6+
- [ ] Read `docs/README.md` - documentation index
7+
</load_documentation>
8+
9+
<tool_preferences>
10+
Use **Serena** for code navigation and editing. Prefer over grep/glob/view for code files.
11+
12+
- `get_symbols_overview`, `find_symbol`, `find_referencing_symbols`, `search_for_pattern`
13+
- `replace_lines`, `delete_lines`, `insert_at_line`, `create_text_file`
14+
15+
Use **Context7** (`resolve-library-id``query-docs`) for external libraries. Do NOT rely on training data.
16+
</tool_preferences>
17+
18+
<documentation_maintenance>
19+
AFTER completing any task, you MUST ask: **"Update docs/?"** if you discovered new patterns, conventions, or architectural decisions.
20+
BEFORE context compaction or when context is running low, SAVE key findings to `docs/` so they are not lost.
21+
Source of truth is `docs/` - update existing files, do NOT create new unless topic does not fit anywhere.
22+
</documentation_maintenance>
23+
</ai_agent_rules>

.vscode/mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"servers": {
3+
"astro": {
4+
"type": "http",
5+
"url": "https://mcp.docs.astro.build/mcp"
6+
}
7+
}
8+
}

CLAUDE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<ai_agent_rules>
2+
MANDATORY - Read before ANY task. Do NOT skip steps.
3+
4+
<load_documentation>
5+
6+
- [ ] Read `docs/README.md` - documentation index
7+
</load_documentation>
8+
9+
<tool_preferences>
10+
Use **Serena** for code navigation and editing. Prefer over grep/glob/view for code files.
11+
12+
- `get_symbols_overview`, `find_symbol`, `find_referencing_symbols`, `search_for_pattern`
13+
- `replace_lines`, `delete_lines`, `insert_at_line`, `create_text_file`
14+
15+
Use **Context7** (`resolve-library-id``query-docs`) for external libraries. Do NOT rely on training data.
16+
</tool_preferences>
17+
18+
<documentation_maintenance>
19+
AFTER completing any task, you MUST ask: **"Update docs/?"** if you discovered new patterns, conventions, or architectural decisions.
20+
BEFORE context compaction or when context is running low, SAVE key findings to `docs/` so they are not lost.
21+
Source of truth is `docs/` - update existing files, do NOT create new unless topic does not fit anywhere.
22+
</documentation_maintenance>
23+
</ai_agent_rules>

astro.config.mjs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ import sitemap from '@astrojs/sitemap';
66
export default defineConfig({
77
site: 'https://lepo.co',
88
// No base path needed for root domain deployment
9+
i18n: {
10+
defaultLocale: 'en',
11+
locales: ['en', 'pl'],
12+
fallback: {
13+
pl: 'en',
14+
},
15+
routing: {
16+
prefixDefaultLocale: false,
17+
fallbackType: 'rewrite',
18+
},
19+
},
920
integrations: [sitemap()],
1021
markdown: {
1122
shikiConfig: {

src/components/FormattedDate.astro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
---
2+
import type { Lang } from '../i18n/ui';
3+
24
export interface Props {
35
date: Date;
6+
lang?: Lang;
47
}
58
6-
const { date } = Astro.props;
7-
const formattedDate = date.toISOString().split('T')[0];
9+
const { date, lang = 'en' } = Astro.props;
10+
const formattedDate = date.toLocaleDateString(lang === 'pl' ? 'pl-PL' : 'en-US', {
11+
year: 'numeric',
12+
month: 'long',
13+
day: 'numeric',
14+
});
815
---
916

1017
<time datetime={date.toISOString()}>

src/components/PostCard.astro

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
---
2+
import { getRelativeLocaleUrl } from 'astro:i18n';
23
import FormattedDate from './FormattedDate.astro';
4+
import { useTranslations } from '../i18n/utils';
5+
import { defaultLang, type Lang } from '../i18n/ui';
36
47
export interface Props {
58
post: {
6-
slug: string;
9+
id: string;
710
data: {
811
title: string;
912
description?: string;
@@ -15,11 +18,14 @@ export interface Props {
1518
externalLink?: string;
1619
};
1720
};
21+
lang?: Lang;
1822
}
1923
24+
const lang = (Astro.currentLocale || defaultLang) as Lang;
25+
const t = useTranslations(lang);
2026
const { post } = Astro.props;
21-
const base = import.meta.env.BASE_URL.endsWith('/') ? import.meta.env.BASE_URL : import.meta.env.BASE_URL + '/';
22-
const postUrl = post.data.externalLink || `${base}posts/${post.slug}/`;
27+
const slug = post.id.replace(/^(en|pl)\//, '');
28+
const postUrl = post.data.externalLink || getRelativeLocaleUrl(lang, `posts/${slug}`);
2329
const isExternal = !!post.data.externalLink;
2430
---
2531

@@ -31,7 +37,7 @@ const isExternal = !!post.data.externalLink;
3137
</h2>
3238
<div class="post-meta">
3339
<time class="post-date">
34-
<FormattedDate date={post.data.pubDate} />
40+
<FormattedDate date={post.data.pubDate} lang={lang} />
3541
</time>
3642
{post.data.author && (
3743
<span class="post-author">{post.data.author}</span>
@@ -41,7 +47,7 @@ const isExternal = !!post.data.externalLink;
4147
<span class="post-tags">
4248
{post.data.tags.map((tag, index) => (
4349
<>
44-
<a href={`${base}tags/${tag}/`}>{tag}</a>{index < post.data.tags.length - 1 && ', '}
50+
<a href={getRelativeLocaleUrl(lang, `tags/${tag}`)}>{tag}</a>{index < post.data.tags.length - 1 && ', '}
4551
</>
4652
))}
4753
</span>
@@ -61,7 +67,7 @@ const isExternal = !!post.data.externalLink;
6167
)}
6268
<div>
6369
<a href={postUrl} class="read-more button inline" target={isExternal ? "_blank" : undefined} rel={isExternal ? "noopener" : undefined}>
64-
[Read more]
70+
{t('post.readMore')}
6571
</a>
6672
</div>
6773
</article>

src/content.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { defineCollection, z } from 'astro:content';
1+
import { defineCollection } from 'astro:content';
2+
import { glob } from 'astro/loaders';
3+
import { z } from 'astro/zod';
24

35
const posts = defineCollection({
4-
type: 'content',
6+
loader: glob({ base: './src/content/posts', pattern: '**/*.{md,mdx}' }),
57
schema: z.object({
68
title: z.string(),
79
description: z.string().optional(),

src/content/posts/building-radiograph-monitoring-app.md renamed to src/content/posts/en/building-radiograph-monitoring-app.md

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)