wpengine / faustjs

Faust.js™ - The Headless WordPress Framework
https://faustjs.org
Other
1.44k stars 134 forks source link

Locale not available when template queries run on client #1983

Open MajesticPagan opened 1 week ago

MajesticPagan commented 1 week ago

Description

I have a query on my wp-templates/page.tsx that is retrieving menuItems based on the current locale:

image

For the variable value for the query I pass the locale that the context object gives me:

image

This works fine when the page is initially rendered server-side but after a few moments, it switches back to the default language. From what I was able to dig up I think it's because of the client-side data fetching done on the WordPressTemplate component, it doesn't pass the locale property here. And since no value is passed, the client query is made without a language being defined, hence the language switch behavior.

Can't deduce if this is the intended behavior and my setup for multilingual is wrong or if Faust.js should be modified to pass the locale here.

My next-intl provider setup on _app.tsx:

image

Steps to reproduce

N/A

Additional context

No response

@faustwp/core Version

^3.1.0

@faustwp/cli Version

^3.1.0

FaustWP Plugin Version

1.4.1

WordPress Version

6.6.2

Additional environment details

Using next-intl v3.17.6 for front-end localization and WPML v4.6.13 and WPML GraphQL v1.1.1 in WordPress.

Please confirm that you have searched existing issues in the repo.