Astro I18next screenshot

Astro I18next

Author Avatar Theme by Yassinedoghri
Updated: 8 Apr 2023
558 Stars

An astro integration of i18next + some utility components to help you translate your astro websites!

Overview:

The astro-i18next is a beta integration of i18next into Astro, providing utility components to help translate Astro websites. The goal of the project is to enhance the developer experience in translating Astro pages, with the possibility of breaking changes before reaching v1.0.0. Users are encouraged to provide feedback during this beta phase to improve the tool.

Features:

  • SSG and SSR Support: Basic examples for Static Site Generation (SSG) and Server-Side Rendering (SSR) in Astro.
  • Utility Components: Includes components like Trans, LanguageSelector, and HeadHrefLangs for easier translation implementation.
  • Utility Functions: Provides functions like interpolate, localizePath, and localizeUrl for additional translation functionalities.
  • Advanced Configuration: Allows for configuration of namespaces and other settings for more customized translation setups.

Installation:

  1. Install the package:
npm install astro-i18next
  1. Configure the package by adding it to your astro.config.mjs file:
// astro.config.mjs
import 'astro-i18next';
  1. Create an astro-i18next config file (astro-i18next.config.mjs) for advanced configuration options.
  2. Start translating your Astro pages using i18next’s t function or the provided Trans component.
  3. Utilize the provided CLI commands like generate for translating routes and generating localized pages.

Summary:

The astro-i18next integration offers Astro developers the tools needed to efficiently translate their websites. With support for SSG, SSR, utility components, and functions, users can streamline the translation process and enhance the internationalization of their Astro projects. Feedback during the beta phase is welcomed to ensure a robust v1.0.0 release.