Help creating localization toggle (accessing locale in Plasmic Studio)

Hi,

Yes, you can solve it in a similar fashion. As you already have the locale value provided by the router, you should be able to provide the “locale” value as data to Plasmic. This way, you can access this data directly into the studio. To be able to access this data, it’s recommended that you add it _app.

You can refer to this project from @alyssa_feola GitHub that implemented the dark mode approach.

In your case it would be something like this:

<DataProvider name="locale" data={locale}>
   <Component {...pageProps} />
</DataProvider>

This way, when you open the data picker, this value will be available to be used in the expressions. You can also change the way that you implemented the switch.

Useful links:

1 Like