0.0.1-alpha.1 • Published 2 years ago

astrojs-i18n v0.0.1-alpha.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

astrojs-i18n

why I use ?

Usage

  • 1.create astro.i18n.config.mjs
const config = {
  defaultLanguage: "en",
  supportedLanguages: ['en','zh'],
  localesPath:{
    loadPath: "./src/locales/*.json",
  },
  i18n: {
    debug: false
  },
}
export default config;
  • 2.write in astro.config.mjs
import i18n from 'astrojs-i18n'
export default defineConfig({
  integrations: [i18n()]
})
  • 3.use in astro components
import { t, changeLanguage } from 'i18next'
changeLanguage('en')
t('title')

Inspired by