From a1d3fb8df0e00faa3920d7f5085a52002e58574e Mon Sep 17 00:00:00 2001 From: Dawid Rycerz Date: Tue, 13 Jan 2026 18:42:05 +0100 Subject: Add polish language support --- src/components/FormattedDate.astro | 5 +-- src/components/blog/Masthead.astro | 18 ++++++++--- src/components/blog/webmentions/Comments.astro | 9 ++++-- src/components/blog/webmentions/Likes.astro | 8 +++-- src/components/blog/webmentions/index.astro | 14 ++++++--- src/content/post/devops-mindset.md | 3 +- src/content/post/fediverse-101.md | 3 +- src/content/post/niedziela-11-wrzesnia-2022.md | 3 +- src/content/post/piatek-16-wrzesnia-2022.md | 3 +- src/content/post/piatek-7-pazdziernika-2022.md | 3 +- src/content/post/piatek-9-wrzesnia-2022.md | 3 +- .../post/poniedzialek-3-pazdziernika-2022.md | 3 +- src/content/post/poniedzialek-5-wrzesnia-2022.md | 3 +- src/content/post/sobota-3-wrzesnia-2022.md | 3 +- src/content/post/sroda-21-wrzesnia-2022.md | 3 +- src/content/post/sroda-28-wrzesnia-2022.md | 3 +- src/content/post/sroda-7-wrzesnia-2022.md | 3 +- src/content/post/wtorek-13-wrzesnia-2022.md | 3 +- src/i18n/translations.ts | 36 ++++++++++++++++++++++ src/layouts/BlogPost.astro | 13 +++++--- src/loaders/pleroma.ts | 8 ++++- src/utils/date.ts | 4 ++- 22 files changed, 118 insertions(+), 36 deletions(-) create mode 100644 src/i18n/translations.ts (limited to 'src') diff --git a/src/components/FormattedDate.astro b/src/components/FormattedDate.astro index 45de273..0c7b2d7 100644 --- a/src/components/FormattedDate.astro +++ b/src/components/FormattedDate.astro @@ -5,11 +5,12 @@ import { getFormattedDate } from "@/utils/date"; type Props = HTMLAttributes<"time"> & { date: Date; dateTimeOptions?: Intl.DateTimeFormatOptions; + locale?: string | undefined; }; -const { date, dateTimeOptions, ...attrs } = Astro.props; +const { date, dateTimeOptions, locale, ...attrs } = Astro.props; -const postDate = getFormattedDate(date, dateTimeOptions); +const postDate = getFormattedDate(date, dateTimeOptions, locale); const ISO = date.toISOString(); --- diff --git a/src/components/blog/Masthead.astro b/src/components/blog/Masthead.astro index 1f52383..e7b3ea9 100644 --- a/src/components/blog/Masthead.astro +++ b/src/components/blog/Masthead.astro @@ -2,15 +2,18 @@ import { Image } from "astro:assets"; import type { CollectionEntry } from "astro:content"; import FormattedDate from "@/components/FormattedDate.astro"; +import { t } from "@/i18n/translations"; interface Props { content: CollectionEntry<"post">; readingTime: string; + language?: string | undefined; } const { content: { data }, readingTime, + language, } = Astro.props; const dateTimeOptions: Intl.DateTimeFormatOptions = { @@ -38,14 +41,21 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = {

- /{" "} + /{ + " " + } {readingTime}

{ data.updatedDate && ( - Updated: - + {t(language, "updated")} + ) } @@ -74,7 +84,7 @@ const dateTimeOptions: Intl.DateTimeFormatOptions = { <> {/* prettier-ignore */} - View more blogs with the tag {tag} + {t(language, "viewMoreWithTag")} {tag} {i < data.tags.length - 1 && ", "} diff --git a/src/components/blog/webmentions/Comments.astro b/src/components/blog/webmentions/Comments.astro index af14bd0..9d274f9 100644 --- a/src/components/blog/webmentions/Comments.astro +++ b/src/components/blog/webmentions/Comments.astro @@ -1,13 +1,15 @@ --- import { Image } from "astro:assets"; import { Icon } from "astro-icon/components"; +import { t } from "@/i18n/translations"; import type { WebmentionsChildren } from "@/types"; interface Props { mentions: WebmentionsChildren[]; + language?: string | undefined; } -const { mentions } = Astro.props; +const { mentions, language } = Astro.props; const validComments = ["mention-of", "in-reply-to"]; @@ -20,7 +22,8 @@ const comments = mentions.filter( !!comments.length && (

- {comments.length} Mention{comments.length > 1 ? "s" : ""} + {comments.length}{" "} + {comments.length > 1 ? t(language, "mentions") : t(language, "mention")}

    {comments.map((mention) => ( @@ -65,7 +68,7 @@ const comments = mentions.filter( target="_blank" >