Is there a way to add a locale path to your URL when you are managing locales with global variants?
For example, if the locale is EN (default), I want the base path to be /
But if the user switches the locale to some other language, I want the base path to be /[locale]
So for locales that isn’t EN, the paths would be something like this:
This is currently not possible with Plasmic Hosting.
But if you’re using loader-nextjs, you can add locales through the nextjs configuration Routing: Internationalization | Next.js
You might also need to pass a CustomLink component to our PlasmicRootProvider that you can configure as you please.
After setting the locale, you will need to change the functions inside your catchall page to use the locale as the global variant value in both the PlasmicLoaderPage and getStaticProps function.
Example:
const locale = context.locale ?? "";
// Cache the necessary data fetched for the page
const queryCache = await extractPlasmicQueryData(
<PlasmicRootProvider
loader={PLASMIC}
prefetchedData={plasmicData}
pageRoute={pageMeta.path}
pageParams={pageMeta.params}
globalVariants={[{ name: 'Locale', value: locale }]}
Link={CustomLink}
>
<PlasmicComponent component={pageMeta.displayName} />
</PlasmicRootProvider>
);