#i18n with strapi ssg

2 messages · Page 1 of 1 (latest)

rose chasm
#

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

coarse carbonBOT
#
No-one around right now?

It looks like no-one has responded to your question yet. People might not be available right now or don’t know how to answer your question. Want an answer while you wait? Try asking our experimental bot in #1095492539085230272.