---
title: Languages
description: Astro i18n, locale folders, the language switcher, hreflang tags and AI translation.
---

Gitupcms follows Astro's `i18n` config. Configure site → **Languages** edits it.

## Turning languages on

- **Enable** on a collection moves its entries into `<base>/<defaultLocale>/` in the same commit. The pattern becomes `**/…` so Astro still loads them (entry ids change).
- In a repo without `i18n`, Gitupcms finds Astro's locale folders (`src/pages/de/`, `src/content/blog/de/`) and offers them as the locales. A default locale with no folder is guessed as `en`.

## Language kit

Languages → **Add a language switcher and hreflang tags** copies two components into `src/components/i18n/`:

```astro src/layouts/Base.astro
---
import { Hreflang, LanguageSwitcher } from "../components/i18n";
---
<html lang={Astro.currentLocale}>
  <head>
    <Hreflang />
  </head>
  <body>
    <LanguageSwitcher />
    <slot />
  </body>
</html>
```

The install adds `<Hreflang />` before `</head>` in layouts that do not already write hreflang, makes `<html lang>` follow `Astro.currentLocale`, and replaces a `{/* gitupcms:language-switcher */}…{/* /gitupcms:language-switcher */}` placeholder with the switcher.

- Both are built on `astro:config/client` (Astro 5.7+), so they follow your Languages settings.
- Hreflang lists only languages whose page file exists, with a self-reference, return tags and `x-default`. It needs `site`.
- Other locales get Astro's `fallback` to the default locale, so switcher links never 404.

## Templates

A template whose astro.config lists `i18n.locales` offers only those languages when you create a site. The new site keeps the ones you pick: the other `src/content/<collection>/<locale>/` folders and `<locale>.json` files are deleted and `i18n` is rewritten.

## AI translation

When you save a change in the AI Editor or Pages, you can translate it to the other languages.

:::warning[Limits]
Translating to 25 languages makes 24 AI calls and can take 1–3 minutes. Hand-edited translations are overwritten. Files with different names per language, and text written directly in `.astro` files, are skipped.
:::
