-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add locale support for visual form builder #7710
Conversation
… creating a new form
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@glaubersilva I think we can simplify this by moving the locale switching higher up the request chain in the places where we are passing the locale from Request to Controller to View Model.
…ress-org/givewp into feature/vfb-locale-support-GIVE-2124
…he service provider
@kjohnson This is ready for re-review. |
Looks like this broke a test:
+ 'edit' => '?locale=en_US'
- 'edit' => null The edit link no longer matches. Was it previously null? |
Build for QA, see https://github.com/impress-org/givewp/actions/runs/13293612151. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passed manual QA tests.
Resolves GIVE-2124
Description
This PR adds support for v3 forms to work with different locales through the use of multilingual plugins. As a bonus, it also allows the creation of new forms respecting the language selected in the WP admin bar through the selectors provided by the WPML and Polylang plugins.
How it's working?
Before, in the
render()
method of theBlockRenderController()
class we are returning adiv
with some data attributes likedata-form-url
that are used in the frontend. Now we also are sending a newdata-form-locale
attribute to be used in the frontend for subsequent requests (donation-form-view
,donation-form-view-preview
, anddonation-confirmation-receipt-view
).Why it works?
Because when the
render()
method of theBlockRenderController()
class is triggered it has the right context of the selected locale, but the subsequent requests made to the server by the frontend (donation-form-view
,donation-form-view-preview
, anddonation-confirmation-receipt-view
) didn't have it before but now they have because the new locale attribute is passed alongside to the subsequent requests and retrieved back in theGive\Framework\Routes\Router
class and then used in the views to make sure we are rendering them with the proper locale.It was inspired by this feature from the Polylang Pro plugin: https://polylang.pro/doc/rest-api/
Affects
The v3 forms.
Visuals
V3 forms - multilingual plugins support
https://www.loom.com/share/99d359f094f4448194965d506ea937ef?sid=bddc70ff-5dee-48fd-a4a2-9b7345c1fbe7
[Bonus Feature] Creating new V3 forms respecting the language selected on the WPML language selector or Polylang Language selector
https://www.loom.com/share/bbd4328a2b2b409784dcce6d3ae3871d?sid=d9e31524-1437-4737-8e46-cfbf5a000ea4
Testing Instructions
V3 forms - multilingual plugins support
[Bonus Feature] Creating new V3 forms respecting the language selected on the WPML language selector or Polylang Language selector
GiveWP > All Forms
page;Pre-review Checklist
@unreleased
tags included in DocBlocks