Shared i18n utilities for Astro projects in the monorepo.
{
"dependencies": {
"@repo/astro-i18n": "workspace:*"
}
}Create an i18n folder in your project with:
- Language JSON files (e.g.,
en.json,ko.json) - A
languages.tsfile to specify supported languages
Example languages.ts:
export const supportedLanguages = ["en", "ko"] as const;
export const defaultLanguage = "en";---
import { initI18n } from "@repo/astro-i18n/astro";
const { language, t } = initI18n(Astro);
---
<h1>{t("common.title")}</h1>@repo/astro-i18n/config- Core i18n configuration and instance creation@repo/astro-i18n/utils- Utility functions (language detection, etc.)@repo/astro-i18n/helpers- Helper functions for extracting translations@repo/astro-i18n/astro- Astro-specific initialization function