├── .changeset ├── README.md └── config.json ├── .github ├── FUNDING.yml └── workflows │ └── build.yml ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── biome.json ├── demo ├── .gitignore ├── .vscode │ ├── extensions.json │ └── launch.json ├── README.md ├── astro.config.ts ├── package.json ├── public │ ├── astrolicious.png │ └── favicon.svg ├── src │ ├── components │ │ ├── Footer.astro │ │ ├── Header.astro │ │ ├── HeroMessage.astro │ │ └── LocaleSwitcher.astro │ ├── content │ │ ├── config.ts │ │ └── posts │ │ │ ├── en │ │ │ └── hello-world.md │ │ │ ├── fr │ │ │ └── bonjour-le-monde.md │ │ │ └── it │ │ │ └── ciao-mondo.md │ ├── env.d.ts │ ├── layouts │ │ └── Layout.astro │ ├── locales │ │ ├── en │ │ │ └── common.json │ │ ├── fr │ │ │ └── common.json │ │ └── it │ │ │ └── common.json │ ├── pages │ │ ├── 404.astro │ │ ├── api │ │ │ └── hello.ts │ │ ├── fr │ │ │ └── test.astro │ │ ├── it │ │ │ └── test.astro │ │ └── test.astro │ └── routes │ │ ├── about.astro │ │ ├── blog.astro │ │ ├── blog │ │ └── [slug].astro │ │ └── index.astro ├── tailwind.config.mjs └── tsconfig.json ├── docs ├── .gitignore ├── .vscode │ ├── extensions.json │ └── launch.json ├── README.md ├── astro.config.ts ├── package.json ├── public │ └── favicon.svg ├── src │ ├── assets │ │ ├── logo-dark.svg │ │ └── logo-light.svg │ ├── content │ │ ├── config.ts │ │ └── docs │ │ │ ├── demo.mdx │ │ │ ├── getting-started │ │ │ ├── installation.mdx │ │ │ ├── known-issues.mdx │ │ │ ├── showcase.mdx │ │ │ └── usage.mdx │ │ │ ├── index.mdx │ │ │ ├── recipes │ │ │ ├── framework-components.mdx │ │ │ ├── get-static-paths.mdx │ │ │ ├── sitemap.mdx │ │ │ └── translated-404-pages.mdx │ │ │ ├── reference │ │ │ ├── components │ │ │ │ ├── i18n-client.mdx │ │ │ │ └── i18n-head.mdx │ │ │ ├── content-collections │ │ │ │ ├── collection-filters.mdx │ │ │ │ └── handle-i18n-slug.mdx │ │ │ ├── types.mdx │ │ │ └── utilities │ │ │ │ ├── get-default-locale-placeholder.mdx │ │ │ │ ├── get-default-locale.mdx │ │ │ │ ├── get-html-attrs.mdx │ │ │ │ ├── get-locale-path.mdx │ │ │ │ ├── get-locale-placeholder.mdx │ │ │ │ ├── get-locale.mdx │ │ │ │ ├── get-locales-placeholder.mdx │ │ │ │ ├── get-locales.mdx │ │ │ │ ├── get-switcher-data.mdx │ │ │ │ ├── set-dynamic-params.mdx │ │ │ │ ├── switch-locale-path.mdx │ │ │ │ └── t.mdx │ │ │ └── usage │ │ │ ├── client.mdx │ │ │ ├── configuration.mdx │ │ │ └── translations.mdx │ ├── env.d.ts │ └── style.css ├── tailwind.config.mjs └── tsconfig.json ├── package.json ├── package ├── CHANGELOG.md ├── README.md ├── assets │ ├── components │ │ ├── I18nClient.astro │ │ └── I18nHead.astro │ ├── middleware.ts │ └── stubs │ │ ├── sitemap.d.ts │ │ ├── virtual.d.ts │ │ └── virtual.mjs ├── env.d.ts ├── package.json ├── src │ ├── content-collections.ts │ ├── i18next │ │ ├── index.ts │ │ ├── namespaces.ts │ │ └── resources.ts │ ├── index.ts │ ├── integration.ts │ ├── internal.ts │ ├── options.ts │ ├── routing │ │ ├── hmr.ts │ │ ├── index.ts │ │ └── register.ts │ ├── sitemap │ │ ├── generate-sitemap.ts │ │ ├── integration.ts │ │ ├── options.ts │ │ ├── route-config.ts │ │ └── utils.ts │ └── types.ts ├── tsconfig.json └── tsup.config.ts ├── playground ├── .gitignore ├── .vscode │ ├── extensions.json │ └── launch.json ├── astro.config.mts ├── package.json ├── public │ └── favicon.svg ├── src │ ├── components │ │ ├── Counter.tsx │ │ └── LocaleSwitcher.astro │ ├── env.d.ts │ ├── layouts │ │ └── Layout.astro │ ├── locales │ │ ├── en │ │ │ ├── common.json │ │ │ └── home.json │ │ └── fr │ │ │ ├── common.json │ │ │ └── home.json │ ├── pages │ │ └── test.astro │ └── routes │ │ ├── TEST-UPPER.astro │ │ ├── about.astro │ │ ├── blog.astro │ │ ├── blog │ │ └── [slug].astro │ │ ├── data.json.ts │ │ ├── index.astro │ │ ├── user.astro │ │ └── user │ │ └── [slug].astro ├── tailwind.config.mjs └── tsconfig.json ├── pnpm-lock.yaml ├── pnpm-workspace.yaml └── scripts └── release.mjs /.changeset/README.md: -------------------------------------------------------------------------------- 1 | # Changesets 2 | 3 | Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works 4 | with multi-package repos, or single-package repos to help you version and publish your code. You can 5 | find the full documentation for it [in our repository](https://github.com/changesets/changesets) 6 | 7 | We have a quick list of common questions to get you started engaging with this project in 8 | [our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) 9 | -------------------------------------------------------------------------------- /.changeset/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://unpkg.com/@changesets/config@3.0.0/schema.json", 3 | "changelog": "@changesets/cli/changelog", 4 | "commit": false, 5 | "fixed": [], 6 | "linked": [], 7 | "access": "public", 8 | "baseBranch": "main", 9 | "updateInternalDependencies": "patch", 10 | "ignore": ["playground", "docs", "demo"] 11 | } 12 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: florian-lefebvre -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout 10 | uses: actions/checkout@v3 11 | 12 | - name: Setup PNPM 13 | run: corepack enable && pnpm -v 14 | 15 | - name: Setup Node 16 | uses: actions/setup-node@v3 17 | with: 18 | node-version: 18.19.0 19 | cache: pnpm 20 | 21 | - name: Install dependencies 22 | run: pnpm install --frozen-lockfile 23 | 24 | - name: Build 25 | run: pnpm --filter @astrolicious/i18n build 26 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.defaultFormatter": "biomejs.biome", 3 | "[mdx]": { 4 | "editor.defaultFormatter": "unifiedjs.vscode-mdx" 5 | }, 6 | "[typescript]": { 7 | "editor.defaultFormatter": "biomejs.biome" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 Florian Lefebvre 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > [!WARNING] 2 | > This integration is unmaintained due to lack of time. It should mostly work but do not expect fixes or new features. 3 | 4 | # @astrolicious/i18n 5 | 6 | Yet another i18n integration for [Astro](https://astro.build/) with server and client utilities, type safety and translations built-in. 7 | 8 | To see how to get started, check out the [package README](./package/README.md) 9 | 10 | ## Licensing 11 | 12 | [MIT Licensed](./LICENSE). Made with ❤️ by [Florian Lefebvre](https://github.com/florian-lefebvre). 13 | -------------------------------------------------------------------------------- /biome.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://biomejs.dev/schemas/1.5.2/schema.json", 3 | "organizeImports": { 4 | "enabled": true 5 | }, 6 | "linter": { 7 | "enabled": true, 8 | "rules": { 9 | "recommended": true, 10 | "suspicious": { 11 | "noExplicitAny": "warn" 12 | } 13 | } 14 | }, 15 | "files": { 16 | "ignore": ["dist", ".astro", ".netlify"] 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /demo/.gitignore: -------------------------------------------------------------------------------- 1 | # build output 2 | dist/ 3 | # generated types 4 | .astro/ 5 | 6 | # dependencies 7 | node_modules/ 8 | 9 | # logs 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | pnpm-debug.log* 14 | 15 | 16 | # environment variables 17 | .env 18 | .env.production 19 | 20 | # macOS-specific files 21 | .DS_Store 22 | 23 | .netlify -------------------------------------------------------------------------------- /demo/.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": ["astro-build.astro-vscode"], 3 | "unwantedRecommendations": [] 4 | } 5 | -------------------------------------------------------------------------------- /demo/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "command": "./node_modules/.bin/astro dev", 6 | "name": "Development server", 7 | "request": "launch", 8 | "type": "node-terminal" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /demo/README.md: -------------------------------------------------------------------------------- 1 | ## I18n for Astro Demo 2 | 3 | 4 | Welcome to the I18n for Astro demo site! This project showcases the capabilities of the I18n for Astro integration, providing a glimpse into the seamless multilingual experience you can create for your website. 5 | 6 | 7 | Please note that this is a demo site meant to highlight the features and possibilities of I18n for Astro. For more information on how to use I18n for Astro in your own projects, please refer to the main repository and documentation. -------------------------------------------------------------------------------- /demo/astro.config.ts: -------------------------------------------------------------------------------- 1 | import react from "@astrojs/react"; 2 | import tailwind from "@astrojs/tailwind"; 3 | import i18n from "@astrolicious/i18n"; 4 | import { defineConfig } from "astro/config"; 5 | 6 | import netlify from "@astrojs/netlify"; 7 | 8 | // https://astro.build/config 9 | export default defineConfig({ 10 | site: "https://astro-i18n-demo.netlify.app", 11 | integrations: [ 12 | i18n({ 13 | defaultLocale: "en", 14 | locales: ["en", "fr", "it"], 15 | pages: { 16 | "/about": { 17 | fr: "/a-propos", 18 | it: "/chi-siamo", 19 | }, 20 | "/blog": { 21 | fr: "/le-blog", 22 | it: "/blog", 23 | }, 24 | "/blog/[slug]": { 25 | fr: "/le-blog/[slug]", 26 | }, 27 | }, 28 | client: { 29 | data: true, 30 | paths: true, 31 | }, 32 | sitemap: true, 33 | }), 34 | tailwind(), 35 | react(), 36 | ], 37 | output: "hybrid", 38 | adapter: netlify({ 39 | imageCDN: false, 40 | }), 41 | }); 42 | -------------------------------------------------------------------------------- /demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "demo", 3 | "type": "module", 4 | "version": "0.0.1", 5 | "private": true, 6 | "scripts": { 7 | "dev": "astro dev", 8 | "start": "astro dev", 9 | "build": "astro check && astro build", 10 | "preview": "astro preview", 11 | "astro": "astro" 12 | }, 13 | "dependencies": { 14 | "@astrojs/check": "^0.5.10", 15 | "@astrojs/netlify": "^5.2.0", 16 | "@astrojs/react": "^3.3.1", 17 | "@astrojs/tailwind": "^5.1.0", 18 | "@astrolicious/i18n": "workspace:*", 19 | "@tailwindcss/forms": "^0.5.7", 20 | "@types/react": "^18.3.1", 21 | "@types/react-dom": "^18.3.0", 22 | "astro": "^4.14.0", 23 | "i18next": "^23.11.3", 24 | "react": "^18.3.1", 25 | "react-dom": "^18.3.1", 26 | "tailwindcss": "^3.4.3", 27 | "typescript": "^5.4.5" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /demo/public/astrolicious.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/astrolicious/i18n/9048f5dd7e9ef8f320f2aa2e0af46da2a2f1ba78/demo/public/astrolicious.png -------------------------------------------------------------------------------- /demo/public/favicon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/components/Footer.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { t } from "i18n:astro"; 3 | --- 4 | 5 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /demo/src/components/Header.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { getLocalePath, t } from "i18n:astro"; 3 | import LocaleSwitcher from "./LocaleSwitcher.astro"; 4 | --- 5 |
6 | 7 |
8 | astrolicious 9 |
astro-i18n demo
10 |
11 |
12 |
13 | {t("home")} 14 | {t("about")} 15 | {t("blog")} 16 |
17 | 18 |
19 | -------------------------------------------------------------------------------- /demo/src/components/HeroMessage.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { t } from "i18n:astro"; 3 | 4 | const { message } = Astro.props; 5 | --- 6 |
7 |

{t(message)}

8 |
9 | -------------------------------------------------------------------------------- /demo/src/components/LocaleSwitcher.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { getLocale, getSwitcherData } from "i18n:astro"; 3 | 4 | const locale = getLocale(); 5 | const data = getSwitcherData(); 6 | --- 7 | 8 | -------------------------------------------------------------------------------- /demo/src/content/config.ts: -------------------------------------------------------------------------------- 1 | import { defineCollection, reference, z } from "astro:content"; 2 | 3 | export const collections = { 4 | posts: defineCollection({ 5 | type: "content", 6 | schema: z.object({ 7 | title: z.string(), 8 | description: z.string(), 9 | author: z.string(), 10 | defaultLocaleVersion: reference("posts").optional(), 11 | }), 12 | }), 13 | }; 14 | -------------------------------------------------------------------------------- /demo/src/content/posts/en/hello-world.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: The Importance of Internationalization (i18n) in Software Development 3 | description: Discover why i18n is crucial for creating software that reaches a global audience and provides an inclusive user experience. 4 | author: Claude 3 Opus 5 | --- 6 | Internationalization, or i18n, is a critical aspect of software development that enables applications to adapt to different languages and cultural conventions. By implementing i18n best practices, developers can create software that reaches a wider global audience, improves user experience, and demonstrates a commitment to inclusivity. Embracing i18n not only helps businesses expand their market reach but also fosters a sense of belonging among users from diverse backgrounds. 7 | -------------------------------------------------------------------------------- /demo/src/content/posts/fr/bonjour-le-monde.md: -------------------------------------------------------------------------------- 1 | --- 2 | defaultLocaleVersion: en/hello-world 3 | title: L'importance de l'internationalisation (i18n) dans le développement de logiciels 4 | description: Découvrez pourquoi l'i18n est essentielle pour créer des logiciels qui atteignent un public mondial et offrent une expérience utilisateur inclusive. 5 | author: Claude 3 Opus 6 | --- 7 | 8 | L'internationalisation, ou i18n, est un aspect essentiel du développement de logiciels qui permet aux applications de s'adapter à différentes langues et conventions culturelles. En mettant en œuvre les meilleures pratiques d'i18n, les développeurs peuvent créer des logiciels qui atteignent un public mondial plus large, améliorent l'expérience utilisateur et démontrent un engagement envers l'inclusivité. L'adoption de l'i18n aide non seulement les entreprises à élargir leur portée sur le marché, mais favorise également un sentiment d'appartenance parmi les utilisateurs de divers horizons. 9 | -------------------------------------------------------------------------------- /demo/src/content/posts/it/ciao-mondo.md: -------------------------------------------------------------------------------- 1 | --- 2 | defaultLocaleVersion: en/hello-world 3 | title: L'importanza dell'internazionalizzazione (i18n) nello sviluppo del software 4 | description: Scopri perché l'i18n è fondamentale per creare software che raggiungano un pubblico globale e forniscano un'esperienza utente inclusiva. 5 | author: Claude 3 Opus 6 | --- 7 | 8 | L'internazionalizzazione, o i18n, è un aspetto critico dello sviluppo del software che consente alle applicazioni di adattarsi a diverse lingue e convenzioni culturali. Implementando le migliori pratiche di i18n, gli sviluppatori possono creare software che raggiungono un pubblico globale più ampio, migliorano l'esperienza utente e dimostrano un impegno verso l'inclusività. Abbracciare l'i18n non solo aiuta le aziende ad espandere la loro portata di mercato, ma promuove anche un senso di appartenenza tra gli utenti di background diversi. -------------------------------------------------------------------------------- /demo/src/env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | /// 3 | /// 4 | /// 5 | -------------------------------------------------------------------------------- /demo/src/layouts/Layout.astro: -------------------------------------------------------------------------------- 1 | --- 2 | import { ViewTransitions } from "astro:transitions"; 3 | import { getHtmlAttrs } from "i18n:astro"; 4 | import I18NClient from "@astrolicious/i18n/components/I18nClient.astro"; 5 | import I18NHead from "@astrolicious/i18n/components/I18nHead.astro"; 6 | import Footer from "../components/Footer.astro"; 7 | import Header from "../components/Header.astro"; 8 | 9 | interface Props { 10 | title: string; 11 | } 12 | 13 | const { title } = Astro.props; 14 | --- 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | {title} 23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 |
31 | 32 |
33 |