faustjs icon indicating copy to clipboard operation
faustjs copied to clipboard

Locale not available when template queries run on client

Open MajesticPagan opened this issue 1 year ago • 1 comments

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.

  • [X] Yes

MajesticPagan avatar Nov 11 '24 13:11 MajesticPagan

Hello @MajesticPagan . Thank you. Would you be able to submit a PR for this if you want?

theodesp avatar Dec 12 '24 13:12 theodesp