Skip to content
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

create caldera_forms_print_translation_strings_in_footer filter #3087

Merged
merged 16 commits into from Mar 15, 2019

Conversation

Shelob9
Copy link
Collaborator

@Shelob9 Shelob9 commented Mar 12, 2019

By default this does nothing. If the filter is set to return true, then the Parsely validtor strings will be printed in the footer.

add_filter( 'caldera_forms_print_translation_strings_in_footer', '__return_true' );

#2962

@Shelob9 Shelob9 added the PR (Patch) Is a pull request label Mar 12, 2019
@Shelob9 Shelob9 added this to the 1.8.3 milestone Mar 12, 2019
@Shelob9 Shelob9 self-assigned this Mar 12, 2019
@Shelob9 Shelob9 requested a review from New0 March 12, 2019 20:08
@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 12, 2019

Screen Shot 2019-03-12 at 4 03 37 PM

@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 12, 2019

Built ZIP file: 1.8.3-alpha.1.zip

@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 13, 2019

New theory, this approach is too complex.

The problem we are trying to solve is Parsely defaults to these strings https://github.com/CalderaWP/Caldera-Forms/blob/master/assets/js/i18n/en.js for validation errors, sometimes it switches out to other languages, so Weglot translates other languages. That makes no sense.

Proposal: If this filter is true, we pass those English strings to wp_localize_script -- Weglot's proposed solution. Else, it works the same way it always did. AND we can put a filter on those strings, which is a requested feature, I'll have to find the issue.

@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 13, 2019

With e073931 the strings are now printed using wp_localize_script(). IF this works for Weglot -- with that filter set to return true. Then I need to make sure that they are actually the strings that get used by parsely. I think we need to replace "<script> setTimeout(function(){window.Parsley.setLocale('$code'); }, 2000 );</script>"; with something like:

window.Parsely.addMessages( $locale, CF_VALIDATOR_STRINGS ); window.Parsley.setLocale($locale); }

@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 13, 2019

1.8.3-alpha.1.zip New build including the last commit.

Copy link
Collaborator

@New0 New0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed a typo and the interpretation of variable as a string.

@Shelob9 Is CF_VALIDATOR_STRINGS printed by default ? Meaning that the filter is used to remove it using add_filter( 'caldera_forms_print_translation_strings_in_footer', '__return_false' );

I'm not make sure if we need to edit the coment l851 or if we change the default to false l854

@New0 New0 marked this pull request as ready for review March 14, 2019 17:33
@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 14, 2019

@New0 your correction is correct.

I want to make sure these strings are used by Parsely.

@Shelob9
Copy link
Collaborator Author

Shelob9 commented Mar 14, 2019

@New0 I refactored a bit in 581174b as this wasn't working for me because my language is en_US and so it was returning early. I confirmed this worked by setting the filter to true, changing the required field message and submitting the form.

In my opinion this should be merged now.

@Shelob9 Shelob9 merged commit 827d7a3 into develop Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR (Patch) Is a pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants