diff --git a/src/components/GeneratorCard.astro b/src/components/GeneratorCard.astro index 9f54261..c43ae90 100644 --- a/src/components/GeneratorCard.astro +++ b/src/components/GeneratorCard.astro @@ -1,14 +1,21 @@ --- import type { Generator } from '../data/generators'; +import { useT } from '../i18n/translations'; +import type { Lang } from '../i18n/translations'; interface Props { generator: Generator; + lang?: Lang; } -const { generator } = Astro.props; -const { slug, title, description, icon, status } = generator; +const { generator, lang = 'en' } = Astro.props; +const T = useT(lang); +const { slug, icon, status } = generator; const isLive = status === 'live'; -const href = `/generators/${slug}/`; +const isRu = lang === 'ru'; +const title = isRu ? generator.ruTitle : generator.title; +const description = isRu ? generator.ruDescription : generator.description; +const href = isRu ? `/ru/generators/${slug}/` : `/generators/${slug}/`; const icons: Record = { hash: ``, @@ -32,7 +39,7 @@ const icons: Record = {

@@ -43,12 +50,12 @@ const icons: Record = { ) : (

{title}

diff --git a/src/components/LanguageSwitcher.astro b/src/components/LanguageSwitcher.astro new file mode 100644 index 0000000..a352d9b --- /dev/null +++ b/src/components/LanguageSwitcher.astro @@ -0,0 +1,41 @@ +--- +interface Props { + lang: 'en' | 'ru'; + alternatePath: string; +} + +const { lang, alternatePath } = Astro.props; +const targetLang = lang === 'en' ? 'ru' : 'en'; +--- + +
+ EN + RU +
+ + diff --git a/src/components/SeoBlock.astro b/src/components/SeoBlock.astro index 7cb73cb..270640d 100644 --- a/src/components/SeoBlock.astro +++ b/src/components/SeoBlock.astro @@ -1,21 +1,26 @@ --- +import { useT } from '../i18n/translations'; +import type { Lang } from '../i18n/translations'; + interface Props { howTo: string[]; whenTo: string[]; + lang?: Lang; } -const { howTo, whenTo } = Astro.props; +const { howTo, whenTo, lang = 'en' } = Astro.props; +const T = useT(lang); ---
-

How to use

+

{T.howToUse}

    {howTo.map((step) =>
  1. {step}
  2. )}
-

When to use

+

{T.whenToUse}

    {whenTo.map((item) =>
  • {item}
  • )}
diff --git a/src/components/generators/CardGenerator.astro b/src/components/generators/CardGenerator.astro index 3217ba8..42c340e 100644 --- a/src/components/generators/CardGenerator.astro +++ b/src/components/generators/CardGenerator.astro @@ -1,33 +1,35 @@ --- -// Interactive card generator — runs on the client via inline script +import { useT } from '../../i18n/translations'; +const isRu = Astro.url.pathname.startsWith('/ru'); +const T = useT(isRu ? 'ru' : 'en'); ---
- +
diff --git a/src/components/generators/PasswordGenerator.astro b/src/components/generators/PasswordGenerator.astro index 92afef6..129acfd 100644 --- a/src/components/generators/PasswordGenerator.astro +++ b/src/components/generators/PasswordGenerator.astro @@ -1,193 +1,115 @@ --- -// Interactive password generator — runs on the client via inline script +import { useT } from '../../i18n/translations'; +const isRu = Astro.url.pathname.startsWith('/ru'); +const T = useT(isRu ? 'ru' : 'en'); ---
-
- + 16
- -
- 464 -
+ +
464
-
{[ - { id: 'pg-upper', label: 'Uppercase (A–Z)' }, - { id: 'pg-lower', label: 'Lowercase (a–z)' }, - { id: 'pg-digits', label: 'Digits (0–9)' }, - { id: 'pg-symbols', label: 'Symbols (!@#…)' }, + { id: 'pg-upper', label: T.uppercase }, + { id: 'pg-lower', label: T.lowercase }, + { id: 'pg-digits', label: T.digits }, + { id: 'pg-symbols', label: T.symbols }, ].map(({ id, label }) => ( ))}
- +
- - - Copied + {T.copied}
-
+