I want to generate a page for two localizations
Here is how I am trying to do it:
import i18next, { t, changeLanguage } from "i18next";
import fetchApi from "../../lib/strapi";
changeLanguage("uk");
export async function getStaticPaths() {
const products: Product[] = await fetchApi<Product[]>({
endpoint: "products?populate=deep",
query: { locale: i18next. language },
wrappedByKey: "data",
});
return products.map((product) => {
return {
params: {slug: product.id},
props: {
name: product.attributes.name
description: product.attributes.description,
shortDescription: product.attributes.shortDescription,
availableForSale: product.attributes.availableForSale,
price: product.attributes.price,
image: product.attributes.image.data.attributes.url,
manufacturer: product.attributes.manufacturer.data,
category: product.attributes.category.data,
specifications: product.attributes.specifications,
features: product.attributes.features
subCategory: product.attributes.subCategory.data,
},
};
});
}
const { name, description, shortDescription, availableForSale, price, image, manufacturer, category, specifications, features, subCategory, } = Astro.props;
I have at the moment due to the fact that in this line query: { locale: i18next.language } I18next.language - undefined I can not generate another language and switch to it in the product itself
I use Astro + Strapi