Closed tiwka19 closed 1 year ago
Sure! Itβs just normal Astro with the additional renders for each locale.
You can import from a single json translation file:
import { getLocale } from "astro-i18n-aut";
import { DEFAULT_LOCALE } from "../consts";
import translations from "../translations/all.json"
const locale = getLocale(Astro.url) ?? DEFAULT_LOCALE;
const translation = translations[locale as keyof typeof translations];
Or from multiple json translation files:
import { getLocale } from "astro-i18n-aut";
import { DEFAULT_LOCALE } from "../consts";
const locale = getLocale(Astro.url) ?? DEFAULT_LOCALE;
const { default: translation } = await import(`../translations/${locale}.json`);
You may be interested in adding a translation framework like https://www.i18next.com/ to handle loading from json files and dealing with things like plurals, interpolation, and formatting if you have a larger website.
is it possible to store translations in json files and access them from astro files?