Changeset 3395670
- Timestamp:
- 11/14/2025 10:47:04 AM (3 months ago)
- Location:
- multilingual-forms-fluent-forms-wpml
- Files:
-
- 7 added
- 3 edited
-
tags/1.0.1 (added)
-
tags/1.0.1/index.php (added)
-
tags/1.0.1/multilingual-forms-for-fluent-forms-with-wpml.php (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/src (added)
-
tags/1.0.1/src/Controllers (added)
-
tags/1.0.1/src/Controllers/SettingsController.php (added)
-
trunk/multilingual-forms-for-fluent-forms-with-wpml.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/src/Controllers/SettingsController.php (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multilingual-forms-fluent-forms-wpml/trunk/multilingual-forms-for-fluent-forms-with-wpml.php
r3291941 r3395670 3 3 * Plugin Name: Multilingual Forms for Fluent Forms with WPML 4 4 * Description: Add multilingual form support for Fluent Forms using WPML. 5 * Author: Dhrupo5 * Author: dhrupo, pyrobd 6 6 * Plugin URI: https://github.com/dhrupo/fluent-forms-wpml 7 7 * Author URI: https://github.com/dhrupo/ 8 * Version: 1.0. 08 * Version: 1.0.1 9 9 * License: GPLv2 or later 10 10 * Text Domain: multilingual-forms-fluent-forms-wpml … … 35 35 define('MFFFWPML_DIR', plugin_dir_path(__FILE__)); 36 36 define('MFFFWPML_URL', plugins_url('', __FILE__)); 37 defined('MFFFWPML_VERSION') or define('MFFFWPML_VERSION', '1.0.1'); 37 38 38 39 class MultilingualFormsFluentFormsWpml -
multilingual-forms-fluent-forms-wpml/trunk/readme.txt
r3291922 r3395670 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 07 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 88 88 == Changelog == 89 89 90 = 1.0.1 = 91 - Fix accordion issue with stdObject 92 90 93 = 1.0.0 = 91 *Initial Release94 - Initial Release 92 95 -
multilingual-forms-fluent-forms-wpml/trunk/src/Controllers/SettingsController.php
r3291922 r3395670 29 29 add_filter('fluentform/ajax_url', [$this, 'setAjaxLanguage'], 10, 1); 30 30 add_filter('fluentform/rendering_form', [$this, 'setWpmlForm'], 10, 1); 31 add_filter('fluentform/recaptcha_lang', [$this, 'setRecaptchaLanguage'], 10, 1); 31 add_filter('fluentform/recaptcha_lang', [$this, 'setCaptchaLanguage'], 10, 1); 32 add_filter('fluentform/hcaptcha_lang', [$this, 'setCaptchaLanguage'], 10, 1); 33 add_filter('fluentform/turnstile_lang', [$this, 'setCaptchaLanguage'], 10, 1); 32 34 33 35 add_filter('fluentform/form_submission_confirmation', [$this, 'translateConfirmationMessage'], 10, 3); … … 44 46 45 47 add_filter('fluentform/input_label_shortcode', [$this, 'translateLabelShortcode'], 10, 3); 48 49 // Pro Module Translation Filters 50 add_filter('fluentform/payment_confirmation_message', [$this, 'translatePaymentMessage'], 10, 3); 51 add_filter('fluentform/quiz_result_title', [$this, 'translateQuizResultTitle'], 10, 3); 52 add_filter('fluentform/quiz_result_message', [$this, 'translateQuizMessage'], 10, 3); 53 add_filter('fluentform/modal_button_text', [$this, 'translateModalText'], 10, 2); 54 add_filter('fluentform/survey_labels', [$this, 'translateSurveyLabels'], 10, 2); 55 add_filter('fluentform/step_form_navigation_title', [$this, 'translateStepNavigation'], 10, 2); 56 add_filter('fluentform/step_next_button_text', [$this, 'translateStepNextButtonText'], 10, 2); 57 add_filter('fluentform/step_prev_button_text', [$this, 'translateStepPrevButtonText'], 10, 2); 58 add_filter('fluentform/file_upload_messages', [$this, 'translateFileUploadMessages'], 10, 2); 59 add_filter('fluentform/double_optin_messages', [$this, 'translateDoubleOptinMessages'], 10, 3); 60 add_filter('fluentform/admin_approval_messages', [$this, 'translateAdminApprovalMessages'], 10, 3); 61 62 // Shortcode Translation Filters 63 add_filter('fluentform/popup_shortcode_defaults', [$this, 'translatePopupShortcodeDefaults'], 10, 2); 64 add_filter('fluentform/survey_shortcode_defaults', [$this, 'translateSurveyShortcodeDefaults'], 10, 2); 65 66 // Specific Pro Component Filters 67 add_filter('fluentform/save_progress_button_text', [$this, 'translateSaveProgressButtonText'], 10, 2); 68 add_filter('fluentform/survey_field_label', [$this, 'translateSurveyFieldLabel'], 10, 2); 69 add_filter('fluentform/survey_votes_text', [$this, 'translateSurveyVotesText'], 10, 2); 70 add_filter('fluentform/double_optin_confirmation_message', [$this, 'translateDoubleOptinConfirmationMessage'], 10, 3); 71 add_filter('fluentform/file_upload_button_text', [$this, 'translateFileUploadButtonText'], 10, 2); 72 73 // Payment-Specific Hooks (All Payment Methods) 74 add_filter('fluentform/payment_success_title', [$this, 'translatePaymentSuccessTitle'], 10, 3); 75 add_filter('fluentform/payment_failed_title', [$this, 'translatePaymentFailedTitle'], 10, 3); 76 add_filter('fluentform/payment_error_message', [$this, 'translatePaymentErrorMessage'], 10, 3); 77 78 // Pro-only payment hooks 79 add_filter('fluentform/payment_pending_title', [$this, 'translatePaymentPendingTitle'], 10, 3); 80 add_filter('fluentform/payment_pending_message', [$this, 'translatePaymentPendingMessage'], 10, 3); 81 82 // Stripe specific 83 add_filter('fluentform/stripe_payment_redirect_message', [$this, 'translateStripePaymentRedirectMessage'], 10, 3); 84 add_filter('fluentform/stripe_payment_cancelled_message', [$this, 'translateStripePaymentCancelledMessage'], 10, 3); 85 86 // Square specific 87 add_filter('fluentform/square_payment_redirect_message', [$this, 'translateSquarePaymentRedirectMessage'], 10, 3); 88 89 // Paystack specific 90 add_filter('fluentform/paystack_payment_modal_opening_message', [$this, 'translatePaystackPaymentModalOpeningMessage'], 10, 3); 91 add_filter('fluentform/paystack_payment_confirming_message', [$this, 'translatePaystackPaymentConfirmingMessage'], 10, 3); 92 add_filter('fluentform/paystack_payment_verification_error', [$this, 'translatePaystackPaymentVerificationError'], 10, 3); 93 94 // PayPal specific 95 add_filter('fluentform/paypal_payment_processing_message', [$this, 'translatePaypalPaymentProcessingMessage'], 10, 3); 96 add_filter('fluentform/paypal_payment_sandbox_message', [$this, 'translatePaypalPaymentSandboxMessage'], 10, 3); 97 add_filter('fluentform/paypal_payment_cancelled_title', [$this, 'translatePaypalPaymentCancelledTitle'], 10, 3); 98 add_filter('fluentform/paypal_payment_cancelled_message', [$this, 'translatePaypalPaymentCancelledMessage'], 10, 3); 99 100 // Form Validation Message Filters 101 add_filter('fluentform/validations', [$this, 'translateValidationMessages'], 10, 3); 102 add_filter('fluentform/validation_error_message', [$this, 'translateValidationErrorMessage'], 10, 3); 103 104 // Conditional Logic 105 add_filter('fluentform/conditional_content', [$this, 'translateConditionalContent'], 10, 3); 106 107 // Advanced Field Message Filters 108 add_filter('fluentform/calculation_field_messages', [$this, 'translateCalculationFieldMessages'], 10, 2); 109 add_filter('fluentform/inventory_field_messages', [$this, 'translateInventoryFieldMessages'], 10, 2); 110 111 // Email Template Filters 112 add_filter('fluentform/email_header', [$this, 'translateEmailTemplateHeader'], 10, 3); 113 add_filter('fluentform/email_footer', [$this, 'translateEmailTemplateFooter'], 10, 3); 114 add_filter('fluentform/email_subject', [$this, 'translateEmailSubjectLine'], 10, 3); 115 116 // Subscription/Recurring Payment Filters 117 add_filter('fluentform/subscription_confirmation_message', [$this, 'translateSubscriptionMessage'], 10, 3); 118 add_filter('fluentform/recurring_payment_message', [$this, 'translateRecurringPaymentMessage'], 10, 3); 119 120 // Submission Message Parse Filter 121 add_filter('fluentform/submission_message_parse', [$this, 'translateSubmissionMessageParse'], 10, 4); 122 123 // JavaScript Frontend Message Filters 124 add_filter('fluentform/form_submission_messages', [$this, 'translateFormSubmissionMessages'], 10, 2); 125 add_filter('fluentform/payment_handler_messages', [$this, 'translatePaymentHandlerMessages'], 10, 2); 126 add_filter('fluentform/form_save_progress_messages', [$this, 'translateFormSaveProgressMessages'], 10, 2); 127 add_filter('fluentform/address_autocomplete_messages', [$this, 'translateAddressAutocompleteMessages'], 10, 2); 128 add_filter('fluentform/payment_gateway_messages', [$this, 'translatePaymentGatewayMessages'], 10, 2); 46 129 47 130 add_filter('fluentform/all_data_shortcode_html', [$this, 'translateAllDataShortcode'],10, 4); … … 117 200 $form->settings = $formSettings; 118 201 119 $formFields = FormFieldsParser::getFields($form );202 $formFields = FormFieldsParser::getFields($form, true); 120 203 $package = $this->getFormPackage($form); 121 204 … … 125 208 // Extract and register strings from submit button 126 209 if (isset($form->fields['submitButton'])) { 127 $submitButton = json_decode(json_encode($form->fields['submitButton']) );210 $submitButton = json_decode(json_encode($form->fields['submitButton']), true); 128 211 $this->extractAndRegisterStrings($submitButton, $formId, $package); 129 212 } … … 131 214 // Extract and register strings from step start elements 132 215 if (isset($form->fields['stepsWrapper']['stepStart'])) { 133 $stepStart = json_decode(json_encode($form->fields['stepsWrapper']['stepStart']) );216 $stepStart = json_decode(json_encode($form->fields['stepsWrapper']['stepStart']), true); 134 217 $this->extractAndRegisterStrings($stepStart, $formId, $package); 135 218 } … … 137 220 // Extract and register strings from step end elements 138 221 if (isset($form->fields['stepsWrapper']['stepEnd'])) { 139 $stepEnd = json_decode(json_encode($form->fields['stepsWrapper']['stepEnd']) );222 $stepEnd = json_decode(json_encode($form->fields['stepsWrapper']['stepEnd']), true); 140 223 $this->extractAndRegisterStrings($stepEnd, $formId, $package); 141 224 } … … 255 338 } 256 339 257 public static function set RecaptchaLanguage($language)340 public static function setCaptchaLanguage($language) 258 341 { 259 342 $currentLanguage = apply_filters('wpml_current_language', null); 260 $allowed = static::getLocales('captcha'); 261 262 if (isset($allowed[$currentLanguage])) { 263 $language = $currentLanguage; 343 344 if (!$currentLanguage) { 345 return $language; 346 } 347 348 // Get the current filter being applied to determine CAPTCHA type 349 $currentFilter = current_filter(); 350 351 if ($currentFilter === 'fluentform/recaptcha_lang') { 352 $allowed = static::getRecaptchaLocales(); 353 if (isset($allowed[$currentLanguage])) { 354 $language = $allowed[$currentLanguage]; 355 } 356 } elseif ($currentFilter === 'fluentform/hcaptcha_lang') { 357 $allowed = static::getHcaptchaLocales(); 358 if (isset($allowed[$currentLanguage])) { 359 $language = $allowed[$currentLanguage]; 360 } 361 } elseif ($currentFilter === 'fluentform/turnstile_lang') { 362 $allowed = static::getTurnstileLocales(); 363 if (isset($allowed[$currentLanguage])) { 364 $language = $allowed[$currentLanguage]; 365 } 264 366 } 265 367 … … 282 384 } 283 385 284 $formFields = FormFieldsParser::getFields($form );386 $formFields = FormFieldsParser::getFields($form, true); 285 387 286 388 $extractedFields = []; … … 291 393 // Extract strings from submit button 292 394 if (isset($form->fields['submitButton'])) { 293 $submitButton = json_decode(json_encode($form->fields['submitButton']) );395 $submitButton = json_decode(json_encode($form->fields['submitButton']), true); 294 396 $this->extractFieldStrings($extractedFields, $submitButton, $form->id); 295 397 } … … 297 399 // Extract strings from step wrapper elements 298 400 if (isset($form->fields['stepsWrapper']['stepStart'])) { 299 $stepStart = json_decode(json_encode($form->fields['stepsWrapper']['stepStart']) );401 $stepStart = json_decode(json_encode($form->fields['stepsWrapper']['stepStart']), true); 300 402 $this->extractFieldStrings($extractedFields, $stepStart, $form->id); 301 403 } 302 404 303 405 if (isset($form->fields['stepsWrapper']['stepEnd'])) { 304 $stepEnd = json_decode(json_encode($form->fields['stepsWrapper']['stepEnd']) );406 $stepEnd = json_decode(json_encode($form->fields['stepsWrapper']['stepEnd']), true); 305 407 $this->extractFieldStrings($extractedFields, $stepEnd, $form->id); 306 408 } … … 346 448 $package = $this->getFormPackage($form); 347 449 348 $confirmation['messageToShow'] = apply_filters('wpml_translate_string', $confirmation['messageToShow'], "form_{$form->id}_confirmation_message", $package); 349 450 // Translate main confirmation message 451 if (!empty($confirmation['messageToShow'])) { 452 $confirmation['messageToShow'] = apply_filters('wpml_translate_string', $confirmation['messageToShow'], "form_{$form->id}_confirmation_message", $package); 453 } 454 455 // Translate success page title if present 456 if (!empty($confirmation['samePageFormBehavior']) && !empty($confirmation['messageToShow'])) { 457 // This is already handled above, but we can add specific handling for different behavior types 458 if (isset($confirmation['successPageTitle'])) { 459 $confirmation['successPageTitle'] = apply_filters('wpml_translate_string', $confirmation['successPageTitle'], "form_{$form->id}_confirmation_page_title", $package); 460 } 461 } 462 350 463 return $confirmation; 351 464 } … … 437 550 438 551 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_keyword_restriction_message", $package); 552 } 553 554 public function translatePaymentMessage($message, $formData, $form) 555 { 556 if (!$this->isWpmlEnabledOnForm($form->id)) { 557 return $message; 558 } 559 560 $package = $this->getFormPackage($form); 561 562 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_payment_message", $package); 563 } 564 565 public function translateQuizMessage($message, $formData, $form) 566 { 567 if (!$this->isWpmlEnabledOnForm($form->id)) { 568 return $message; 569 } 570 571 $package = $this->getFormPackage($form); 572 573 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_quiz_message", $package); 574 } 575 576 public function translateModalText($text, $form) 577 { 578 if (!$this->isWpmlEnabledOnForm($form->id)) { 579 return $text; 580 } 581 582 $package = $this->getFormPackage($form); 583 584 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_modal_text", $package); 585 } 586 587 public function translateSurveyLabels($labels, $form) 588 { 589 if (!$this->isWpmlEnabledOnForm($form->id)) { 590 return $labels; 591 } 592 593 $package = $this->getFormPackage($form); 594 595 if (is_array($labels)) { 596 foreach ($labels as $key => $label) { 597 $labels[$key] = apply_filters('wpml_translate_string', $label, "form_{$form->id}_survey_label_{$key}", $package); 598 } 599 } else { 600 $labels = apply_filters('wpml_translate_string', $labels, "form_{$form->id}_survey_labels", $package); 601 } 602 603 return $labels; 604 } 605 606 public function translateStepNavigation($navigation, $form) 607 { 608 if (!$this->isWpmlEnabledOnForm($form->id)) { 609 return $navigation; 610 } 611 612 $package = $this->getFormPackage($form); 613 614 if (isset($navigation['next_btn_text'])) { 615 $navigation['next_btn_text'] = apply_filters('wpml_translate_string', $navigation['next_btn_text'], "form_{$form->id}_step_next_btn", $package); 616 } 617 618 if (isset($navigation['prev_btn_text'])) { 619 $navigation['prev_btn_text'] = apply_filters('wpml_translate_string', $navigation['prev_btn_text'], "form_{$form->id}_step_prev_btn", $package); 620 } 621 622 if (isset($navigation['step_title'])) { 623 $navigation['step_title'] = apply_filters('wpml_translate_string', $navigation['step_title'], "form_{$form->id}_step_title", $package); 624 } 625 626 return $navigation; 627 } 628 629 public function translateFileUploadMessages($messages, $form) 630 { 631 if (!$this->isWpmlEnabledOnForm($form->id)) { 632 return $messages; 633 } 634 635 $package = $this->getFormPackage($form); 636 637 $translatableKeys = [ 638 'drag_drop_text' => 'file_drag_drop_text', 639 'upload_text' => 'file_upload_text', 640 'max_file_error' => 'file_max_error', 641 'file_type_error' => 'file_type_error', 642 'file_size_error' => 'file_size_error', 643 'upload_failed_text' => 'file_upload_failed_text', 644 'upload_error_text' => 'file_upload_error_text' 645 ]; 646 647 foreach ($translatableKeys as $key => $translationKey) { 648 if (isset($messages[$key])) { 649 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 650 } 651 } 652 653 return $messages; 654 } 655 656 public function translateDoubleOptinMessages($messages, $formData, $form) 657 { 658 if (!$this->isWpmlEnabledOnForm($form->id)) { 659 return $messages; 660 } 661 662 $package = $this->getFormPackage($form); 663 664 $translatableKeys = [ 665 'confirmation_message' => 'optin_confirmation_message', 666 'email_subject' => 'optin_email_subject', 667 'email_body' => 'optin_email_body', 668 'success_message' => 'optin_success_message', 669 'error_message' => 'optin_error_message' 670 ]; 671 672 foreach ($translatableKeys as $key => $translationKey) { 673 if (isset($messages[$key])) { 674 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 675 } 676 } 677 678 return $messages; 679 } 680 681 public function translateAdminApprovalMessages($messages, $formData, $form) 682 { 683 if (!$this->isWpmlEnabledOnForm($form->id)) { 684 return $messages; 685 } 686 687 $package = $this->getFormPackage($form); 688 689 $translatableKeys = [ 690 'approval_message' => 'approval_pending_message', 691 'approved_message' => 'approval_approved_message', 692 'rejected_message' => 'approval_rejected_message', 693 'notification_subject' => 'approval_notification_subject', 694 'notification_body' => 'approval_notification_body' 695 ]; 696 697 foreach ($translatableKeys as $key => $translationKey) { 698 if (isset($messages[$key])) { 699 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 700 } 701 } 702 703 return $messages; 704 } 705 706 public function translatePopupShortcodeDefaults($defaults, $atts) 707 { 708 if (!isset($atts['form_id'])) { 709 return $defaults; 710 } 711 712 $formId = intval($atts['form_id']); 713 if (!$this->isWpmlEnabledOnForm($formId)) { 714 return $defaults; 715 } 716 717 $form = (object)['id' => $formId]; 718 $package = $this->getFormPackage($form); 719 720 // Translate default button text 721 if (isset($defaults['btn_text'])) { 722 $defaults['btn_text'] = apply_filters('wpml_translate_string', $defaults['btn_text'], "form_{$formId}_modal_button_text", $package); 723 } 724 725 return $defaults; 726 } 727 728 public function translateSurveyShortcodeDefaults($defaults, $atts) 729 { 730 if (!isset($atts['form_id'])) { 731 return $defaults; 732 } 733 734 $formId = intval($atts['form_id']); 735 if (!$this->isWpmlEnabledOnForm($formId)) { 736 return $defaults; 737 } 738 739 $form = (object)['id' => $formId]; 740 $package = $this->getFormPackage($form); 741 742 // Translate default labels 743 $translatableKeys = ['label', 'counts']; 744 foreach ($translatableKeys as $key) { 745 if (isset($defaults[$key])) { 746 $defaults[$key] = apply_filters('wpml_translate_string', $defaults[$key], "form_{$formId}_survey_{$key}_default", $package); 747 } 748 } 749 750 return $defaults; 751 } 752 753 public function translateSaveProgressButtonText($text, $form) 754 { 755 if (!$this->isWpmlEnabledOnForm($form->id)) { 756 return $text; 757 } 758 759 $package = $this->getFormPackage($form); 760 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_save_progress_button_text", $package); 761 } 762 763 public function translateSurveyFieldLabel($label, $form) 764 { 765 if (!$this->isWpmlEnabledOnForm($form->id)) { 766 return $label; 767 } 768 769 $package = $this->getFormPackage($form); 770 return apply_filters('wpml_translate_string', $label, "form_{$form->id}_survey_field_label", $package); 771 } 772 773 public function translateSurveyVotesText($text, $form) 774 { 775 if (!$this->isWpmlEnabledOnForm($form->id)) { 776 return $text; 777 } 778 779 $package = $this->getFormPackage($form); 780 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_survey_votes_text", $package); 781 } 782 783 public function translateDoubleOptinConfirmationMessage($message, $formData, $form) 784 { 785 if (!$this->isWpmlEnabledOnForm($form->id)) { 786 return $message; 787 } 788 789 $package = $this->getFormPackage($form); 790 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_double_optin_confirmation", $package); 791 } 792 793 public function translateFileUploadButtonText($text, $form) 794 { 795 if (!$this->isWpmlEnabledOnForm($form->id)) { 796 return $text; 797 } 798 799 $package = $this->getFormPackage($form); 800 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_file_upload_button_text", $package); 801 } 802 803 public function translatePaymentSuccessTitle($title, $submission, $form) 804 { 805 if (!$this->isWpmlEnabledOnForm($form->id)) { 806 return $title; 807 } 808 809 $package = $this->getFormPackage($form); 810 return apply_filters('wpml_translate_string', $title, "form_{$form->id}_payment_success_title", $package); 811 } 812 813 public function translatePaymentFailedTitle($title, $submission, $form) 814 { 815 if (!$this->isWpmlEnabledOnForm($form->id)) { 816 return $title; 817 } 818 819 $package = $this->getFormPackage($form); 820 return apply_filters('wpml_translate_string', $title, "form_{$form->id}_payment_failed_title", $package); 821 } 822 823 public function translatePaymentPendingTitle($title, $submission, $form) 824 { 825 if (!$this->isWpmlEnabledOnForm($form->id)) { 826 return $title; 827 } 828 829 $package = $this->getFormPackage($form); 830 return apply_filters('wpml_translate_string', $title, "form_{$form->id}_payment_pending_title", $package); 831 } 832 833 public function translatePaymentPendingMessage($message, $submission, $form) 834 { 835 if (!$this->isWpmlEnabledOnForm($form->id)) { 836 return $message; 837 } 838 839 $package = $this->getFormPackage($form); 840 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_payment_pending_message", $package); 841 } 842 843 public function translatePaymentErrorMessage($message, $submission, $form) 844 { 845 if (!$this->isWpmlEnabledOnForm($form->id)) { 846 return $message; 847 } 848 849 $package = $this->getFormPackage($form); 850 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_payment_error_message", $package); 851 } 852 853 public function translateStripePaymentRedirectMessage($message, $submission, $form) 854 { 855 if (!$this->isWpmlEnabledOnForm($form->id)) { 856 return $message; 857 } 858 859 $package = $this->getFormPackage($form); 860 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_stripe_payment_redirect_message", $package); 861 } 862 863 public function translateSquarePaymentRedirectMessage($message, $submission, $form) 864 { 865 if (!$this->isWpmlEnabledOnForm($form->id)) { 866 return $message; 867 } 868 869 $package = $this->getFormPackage($form); 870 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_square_payment_redirect_message", $package); 871 } 872 873 public function translatePaystackPaymentModalOpeningMessage($message, $submission, $form) 874 { 875 if (!$this->isWpmlEnabledOnForm($form->id)) { 876 return $message; 877 } 878 879 $package = $this->getFormPackage($form); 880 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paystack_payment_modal_opening_message", $package); 881 } 882 883 public function translatePaystackPaymentConfirmingMessage($message, $submission, $form) 884 { 885 if (!$this->isWpmlEnabledOnForm($form->id)) { 886 return $message; 887 } 888 889 $package = $this->getFormPackage($form); 890 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paystack_payment_confirming_message", $package); 891 } 892 893 public function translatePaystackPaymentVerificationError($message, $submission, $form) 894 { 895 if (!$this->isWpmlEnabledOnForm($form->id)) { 896 return $message; 897 } 898 899 $package = $this->getFormPackage($form); 900 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paystack_payment_verification_error", $package); 901 } 902 903 public function translateQuizResultTitle($title, $submission, $form) 904 { 905 if (!$this->isWpmlEnabledOnForm($form->id)) { 906 return $title; 907 } 908 909 $package = $this->getFormPackage($form); 910 return apply_filters('wpml_translate_string', $title, "form_{$form->id}_quiz_result_title", $package); 911 } 912 913 public function translateStepNextButtonText($text, $data) 914 { 915 if (!isset($data['container']['form_instance'])) { 916 return $text; 917 } 918 919 $form = $data['container']['form_instance']; 920 if (!$this->isWpmlEnabledOnForm($form->id)) { 921 return $text; 922 } 923 924 $package = $this->getFormPackage($form); 925 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_step_next_button_text", $package); 926 } 927 928 public function translateStepPrevButtonText($text, $data) 929 { 930 if (!isset($data['container']['form_instance'])) { 931 return $text; 932 } 933 934 $form = $data['container']['form_instance']; 935 if (!$this->isWpmlEnabledOnForm($form->id)) { 936 return $text; 937 } 938 939 $package = $this->getFormPackage($form); 940 return apply_filters('wpml_translate_string', $text, "form_{$form->id}_step_prev_button_text", $package); 941 } 942 943 public function translateStripePaymentCancelledMessage($message, $submission, $form) 944 { 945 if (!$this->isWpmlEnabledOnForm($form->id)) { 946 return $message; 947 } 948 949 $package = $this->getFormPackage($form); 950 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_stripe_payment_cancelled_message", $package); 951 } 952 953 public function translatePaypalPaymentProcessingMessage($message, $submission, $form) 954 { 955 if (!$this->isWpmlEnabledOnForm($form->id)) { 956 return $message; 957 } 958 959 $package = $this->getFormPackage($form); 960 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paypal_payment_processing_message", $package); 961 } 962 963 public function translatePaypalPaymentSandboxMessage($message, $submission, $form) 964 { 965 if (!$this->isWpmlEnabledOnForm($form->id)) { 966 return $message; 967 } 968 969 $package = $this->getFormPackage($form); 970 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paypal_payment_sandbox_message", $package); 971 } 972 973 public function translatePaypalPaymentCancelledTitle($title, $submission, $form) 974 { 975 if (!$this->isWpmlEnabledOnForm($form->id)) { 976 return $title; 977 } 978 979 $package = $this->getFormPackage($form); 980 return apply_filters('wpml_translate_string', $title, "form_{$form->id}_paypal_payment_cancelled_title", $package); 981 } 982 983 public function translatePaypalPaymentCancelledMessage($message, $submission, $form) 984 { 985 if (!$this->isWpmlEnabledOnForm($form->id)) { 986 return $message; 987 } 988 989 $package = $this->getFormPackage($form); 990 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_paypal_payment_cancelled_message", $package); 991 } 992 993 public function translateValidationMessages($validations, $form, $formData) 994 { 995 if (!$this->isWpmlEnabledOnForm($form->id)) { 996 return $validations; 997 } 998 999 $package = $this->getFormPackage($form); 1000 list($rules, $messages) = $validations; 1001 1002 // Translate validation messages 1003 foreach ($messages as $key => $message) { 1004 $translationKey = "form_{$form->id}_validation_" . str_replace('.', '_', $key); 1005 $messages[$key] = apply_filters('wpml_translate_string', $message, $translationKey, $package); 1006 } 1007 1008 return [$rules, $messages]; 1009 } 1010 1011 public function translateValidationErrorMessage($message, $field, $form) 1012 { 1013 if (!$this->isWpmlEnabledOnForm($form->id)) { 1014 return $message; 1015 } 1016 1017 $package = $this->getFormPackage($form); 1018 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_validation_error_message", $package); 1019 } 1020 1021 public function translateConditionalContent($content, $formData, $form) 1022 { 1023 if (!$this->isWpmlEnabledOnForm($form->id)) { 1024 return $content; 1025 } 1026 1027 $package = $this->getFormPackage($form); 1028 return apply_filters('wpml_translate_string', $content, "form_{$form->id}_conditional_content", $package); 1029 } 1030 1031 public function translateStepValidationMessage($message, $formData, $form) 1032 { 1033 if (!$this->isWpmlEnabledOnForm($form->id)) { 1034 return $message; 1035 } 1036 1037 $package = $this->getFormPackage($form); 1038 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_step_validation_message", $package); 1039 } 1040 1041 public function translateRepeaterFieldMessages($messages, $form) 1042 { 1043 if (!$this->isWpmlEnabledOnForm($form->id)) { 1044 return $messages; 1045 } 1046 1047 $package = $this->getFormPackage($form); 1048 1049 $translatableKeys = [ 1050 'add_more_text' => 'repeater_add_more_text', 1051 'remove_text' => 'repeater_remove_text', 1052 'max_repeat_error' => 'repeater_max_repeat_error', 1053 'min_repeat_error' => 'repeater_min_repeat_error' 1054 ]; 1055 1056 foreach ($translatableKeys as $key => $translationKey) { 1057 if (isset($messages[$key])) { 1058 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 1059 } 1060 } 1061 1062 return $messages; 1063 } 1064 1065 public function translateCalculationFieldMessages($messages, $form) 1066 { 1067 if (!$this->isWpmlEnabledOnForm($form->id)) { 1068 return $messages; 1069 } 1070 1071 $package = $this->getFormPackage($form); 1072 1073 $translatableKeys = [ 1074 'calculation_error' => 'calculation_error_message', 1075 'invalid_formula' => 'calculation_invalid_formula', 1076 'division_by_zero' => 'calculation_division_by_zero' 1077 ]; 1078 1079 foreach ($translatableKeys as $key => $translationKey) { 1080 if (isset($messages[$key])) { 1081 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 1082 } 1083 } 1084 1085 return $messages; 1086 } 1087 1088 public function translateInventoryFieldMessages($messages, $form) 1089 { 1090 if (!$this->isWpmlEnabledOnForm($form->id)) { 1091 return $messages; 1092 } 1093 1094 $package = $this->getFormPackage($form); 1095 1096 $translatableKeys = [ 1097 'out_of_stock' => 'inventory_out_of_stock', 1098 'insufficient_stock' => 'inventory_insufficient_stock', 1099 'stock_limit_reached' => 'inventory_stock_limit_reached' 1100 ]; 1101 1102 foreach ($translatableKeys as $key => $translationKey) { 1103 if (isset($messages[$key])) { 1104 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 1105 } 1106 } 1107 1108 return $messages; 439 1109 } 440 1110 … … 474 1144 } 475 1145 } 476 1146 1147 // Pro Integration Feeds (ActiveCampaign, Zapier, etc.) 1148 $proIntegrations = [ 1149 'activecampaign', 'campaignmonitor', 'constantcontact', 'convertkit', 'getresponse', 1150 'hubspot', 'icontact', 'moosend', 'platformly', 'webhook', 'zapier', 'sendfox', 1151 'mailerlite', 'sms_notification', 'getgist', 'googlesheet', 'trello', 'drip', 1152 'sendinblue', 'user_registration', 'automizy', 'telegram', 'salesflare', 'discord', 1153 'cleverreach', 'clicksend', 'zohocrm', 'pipedrive', 'salesforce', 'amocrm', 1154 'onepagecrm', 'airtable', 'mailjet', 'insightly', 'mailster', 'notion' 1155 ]; 1156 1157 $metaKey = ArrayHelper::get($feed, 'meta_key'); 1158 if (in_array($metaKey, $proIntegrations)) { 1159 // Common translatable integration settings 1160 $translatableKeys = [ 1161 'success_message' => 'integration_success_message', 1162 'error_message' => 'integration_error_message', 1163 'confirmation_message' => 'integration_confirmation_message', 1164 'email_subject' => 'integration_email_subject', 1165 'email_body' => 'integration_email_body', 1166 'webhook_success_message' => 'webhook_success_message', 1167 'webhook_error_message' => 'webhook_error_message', 1168 'list_name' => 'integration_list_name', 1169 'tag_name' => 'integration_tag_name', 1170 'note' => 'integration_note', 1171 'description' => 'integration_description' 1172 ]; 1173 1174 foreach ($translatableKeys as $settingKey => $translationKey) { 1175 if (isset($feed['settings'][$settingKey])) { 1176 $key = "form_{$formId}_feed_{$id}_{$translationKey}"; 1177 $feed['settings'][$settingKey] = apply_filters('wpml_translate_string', $feed['settings'][$settingKey], $key, $package); 1178 } 1179 } 1180 1181 // Handle nested settings for complex integrations 1182 if (isset($feed['settings']['fields']) && is_array($feed['settings']['fields'])) { 1183 foreach ($feed['settings']['fields'] as $fieldKey => &$fieldValue) { 1184 if (is_string($fieldValue) && !empty($fieldValue)) { 1185 $key = "form_{$formId}_feed_{$id}_field_{$fieldKey}"; 1186 $fieldValue = apply_filters('wpml_translate_string', $fieldValue, $key, $package); 1187 } 1188 } 1189 } 1190 } 1191 1192 // Payment Integration Messages 1193 if (strpos($metaKey, 'payment_') === 0 || in_array($metaKey, ['paypal', 'stripe', 'razorpay', 'mollie', 'paystack'])) { 1194 $paymentKeys = [ 1195 'payment_success_message' => 'payment_success_message', 1196 'payment_error_message' => 'payment_error_message', 1197 'receipt_template' => 'payment_receipt_template', 1198 'confirmation_message' => 'payment_confirmation_message' 1199 ]; 1200 1201 foreach ($paymentKeys as $settingKey => $translationKey) { 1202 if (isset($feed['settings'][$settingKey])) { 1203 $key = "form_{$formId}_payment_{$id}_{$translationKey}"; 1204 $feed['settings'][$settingKey] = apply_filters('wpml_translate_string', $feed['settings'][$settingKey], $key, $package); 1205 } 1206 } 1207 } 1208 477 1209 return $feed; 478 1210 } … … 517 1249 private function extractFieldStrings(&$fields, $field, $formId, $prefix = '') 518 1250 { 1251 if (is_array($field)) { 1252 $field = json_decode(json_encode($field)); 1253 } 1254 519 1255 $fieldIdentifier = isset($field->attributes->name) ? $field->attributes->name : 520 1256 (isset($field->uniqElKey) ? $field->uniqElKey : null); … … 560 1296 } 561 1297 1298 if (!empty($field->settings->prefix_label)) { 1299 $fields["{$fieldIdentifier}->prefix_label"] = $field->settings->prefix_label; 1300 } 1301 1302 if (!empty($field->settings->suffix_label)) { 1303 $fields["{$fieldIdentifier}->suffix_label"] = $field->settings->suffix_label; 1304 } 1305 562 1306 // Handle validation messages 563 1307 if (!empty($field->settings->validation_rules)) { … … 565 1309 if (!empty($details->message)) { 566 1310 $fields["{$fieldIdentifier}->Validation Rules->{$rule}"] = $details->message; 1311 } 1312 } 1313 } 1314 1315 // Handle unique validation message 1316 if (!empty($field->settings->unique_validation_message)) { 1317 $fields["{$fieldIdentifier}->unique_validation_message"] = $field->settings->unique_validation_message; 1318 } 1319 1320 // Handle inventory/stock messages 1321 if (!empty($field->settings->inventory_stockout_message)) { 1322 $fields["{$fieldIdentifier}->inventory_stockout_message"] = $field->settings->inventory_stockout_message; 1323 } 1324 1325 if (!empty($field->settings->stock_quantity_label)) { 1326 $fields["{$fieldIdentifier}->stock_quantity_label"] = $field->settings->stock_quantity_label; 1327 } 1328 1329 // Handle conditional logic group titles 1330 if (!empty($field->settings->conditional_logics->condition_groups)) { 1331 foreach ($field->settings->conditional_logics->condition_groups as $groupIndex => $group) { 1332 if (!empty($group->title)) { 1333 $fields["{$fieldIdentifier}->conditional_logics->condition_groups->{$groupIndex}->title"] = $group->title; 567 1334 } 568 1335 } … … 820 1587 } 821 1588 break; 1589 1590 case 'save_progress_button': 1591 // Extract save progress button messages and email templates 1592 if (!empty($field->settings->save_success_message)) { 1593 $fields["{$fieldIdentifier}->save_success_message"] = $field->settings->save_success_message; 1594 } 1595 1596 if (!empty($field->settings->email_subject)) { 1597 $fields["{$fieldIdentifier}->email_subject"] = $field->settings->email_subject; 1598 } 1599 1600 if (!empty($field->settings->email_body)) { 1601 $fields["{$fieldIdentifier}->email_body"] = $field->settings->email_body; 1602 } 1603 1604 if (!empty($field->settings->on_create_email_subject)) { 1605 $fields["{$fieldIdentifier}->on_create_email_subject"] = $field->settings->on_create_email_subject; 1606 } 1607 1608 if (!empty($field->settings->on_create_email_body)) { 1609 $fields["{$fieldIdentifier}->on_create_email_body"] = $field->settings->on_create_email_body; 1610 } 1611 1612 if (!empty($field->settings->on_update_email_subject)) { 1613 $fields["{$fieldIdentifier}->on_update_email_subject"] = $field->settings->on_update_email_subject; 1614 } 1615 1616 if (!empty($field->settings->on_update_email_body)) { 1617 $fields["{$fieldIdentifier}->on_update_email_body"] = $field->settings->on_update_email_body; 1618 } 1619 break; 1620 1621 case 'ratings': 1622 // Extract rating options labels 1623 if (!empty($field->options)) { 1624 foreach ($field->options as $value => $label) { 1625 if (!empty($label)) { 1626 $fields["{$fieldIdentifier}->Rating Options->{$value}"] = $label; 1627 } 1628 } 1629 } 1630 break; 1631 1632 case 'select_country': 1633 // Extract country options labels 1634 if (!empty($field->options)) { 1635 foreach ($field->options as $value => $label) { 1636 if (!empty($label)) { 1637 $fields["{$fieldIdentifier}->Country Options->{$value}"] = $label; 1638 } 1639 } 1640 } 1641 break; 1642 1643 case 'chained_select': 1644 // Extract chained select data source headers 1645 if (!empty($field->settings->data_source->headers)) { 1646 foreach ($field->settings->data_source->headers as $index => $header) { 1647 if (!empty($header)) { 1648 $fields["{$fieldIdentifier}->data_source->headers->{$index}"] = $header; 1649 } 1650 } 1651 } 1652 break; 1653 1654 case 'recaptcha': 1655 case 'hcaptcha': 1656 case 'turnstile': 1657 // These CAPTCHA fields only have labels that are handled by common field processing 1658 // No additional field-specific translatable content 1659 break; 822 1660 } 823 1661 } … … 829 1667 830 1668 // Confirmation settings 831 if (isset($settings['formSettings'][0]['confirmation']['messageToShow'])) { 832 $extractedStrings["form_{$formId}_confirmation_message"] = $settings['formSettings'][0]['confirmation']['messageToShow']; 1669 if (isset($settings['formSettings'][0]['confirmation'])) { 1670 $confirmation = $settings['formSettings'][0]['confirmation']; 1671 1672 // Main confirmation message 1673 if (isset($confirmation['messageToShow'])) { 1674 $extractedStrings["form_{$formId}_confirmation_message"] = $confirmation['messageToShow']; 1675 } 1676 1677 1678 1679 // Custom page HTML content 1680 if (isset($confirmation['customPageHtml'])) { 1681 $extractedStrings["form_{$formId}_confirmation_custom_page"] = $confirmation['customPageHtml']; 1682 } 1683 1684 // Success page title 1685 if (isset($confirmation['successPageTitle'])) { 1686 $extractedStrings["form_{$formId}_confirmation_page_title"] = $confirmation['successPageTitle']; 1687 } 833 1688 } 834 1689 … … 917 1772 $extractedStrings["form_{$formId}_advanced_validation_error"] = $validationSettings['error_message']; 918 1773 break; // Only process the first one 1774 } 1775 } 1776 } 1777 1778 // Payment Settings 1779 if (isset($settings['payment_settings'])) { 1780 foreach ($settings['payment_settings'] as $index => $paymentSettings) { 1781 if (isset($paymentSettings['confirmation_message'])) { 1782 $extractedStrings["form_{$formId}_payment_confirmation_{$index}"] = $paymentSettings['confirmation_message']; 1783 } 1784 if (isset($paymentSettings['error_message'])) { 1785 $extractedStrings["form_{$formId}_payment_error_{$index}"] = $paymentSettings['error_message']; 1786 } 1787 if (isset($paymentSettings['receipt_template'])) { 1788 $extractedStrings["form_{$formId}_payment_receipt_{$index}"] = $paymentSettings['receipt_template']; 1789 } 1790 } 1791 } 1792 1793 // Quiz Settings 1794 if (isset($settings['quiz_settings'])) { 1795 foreach ($settings['quiz_settings'] as $index => $quizSettings) { 1796 if (isset($quizSettings['result_message'])) { 1797 $extractedStrings["form_{$formId}_quiz_result_{$index}"] = $quizSettings['result_message']; 1798 } 1799 if (isset($quizSettings['pass_message'])) { 1800 $extractedStrings["form_{$formId}_quiz_pass_{$index}"] = $quizSettings['pass_message']; 1801 } 1802 if (isset($quizSettings['fail_message'])) { 1803 $extractedStrings["form_{$formId}_quiz_fail_{$index}"] = $quizSettings['fail_message']; 1804 } 1805 } 1806 } 1807 1808 // Modal Settings 1809 if (isset($settings['modal_settings'])) { 1810 if (isset($settings['modal_settings']['button_text'])) { 1811 $extractedStrings["form_{$formId}_modal_button_text"] = $settings['modal_settings']['button_text']; 1812 } 1813 if (isset($settings['modal_settings']['modal_title'])) { 1814 $extractedStrings["form_{$formId}_modal_title"] = $settings['modal_settings']['modal_title']; 1815 } 1816 } 1817 1818 // Step Form Settings 1819 if (isset($settings['step_form_settings'])) { 1820 if (isset($settings['step_form_settings']['next_btn_text'])) { 1821 $extractedStrings["form_{$formId}_step_next_btn"] = $settings['step_form_settings']['next_btn_text']; 1822 } 1823 if (isset($settings['step_form_settings']['prev_btn_text'])) { 1824 $extractedStrings["form_{$formId}_step_prev_btn"] = $settings['step_form_settings']['prev_btn_text']; 1825 } 1826 } 1827 1828 // File Upload Settings 1829 if (isset($settings['file_upload_settings'])) { 1830 $fileUploadKeys = [ 1831 'drag_drop_text' => 'file_drag_drop_text', 1832 'upload_text' => 'file_upload_text', 1833 'max_file_error' => 'file_max_error', 1834 'file_type_error' => 'file_type_error', 1835 'file_size_error' => 'file_size_error' 1836 ]; 1837 1838 foreach ($fileUploadKeys as $key => $translationKey) { 1839 if (isset($settings['file_upload_settings'][$key])) { 1840 $extractedStrings["form_{$formId}_{$translationKey}"] = $settings['file_upload_settings'][$key]; 1841 } 1842 } 1843 } 1844 1845 // Pro Integration Feeds 1846 $proIntegrations = [ 1847 'activecampaign', 'campaignmonitor', 'constantcontact', 'convertkit', 'getresponse', 1848 'hubspot', 'icontact', 'moosend', 'platformly', 'webhook', 'zapier', 'sendfox', 1849 'mailerlite', 'sms_notification', 'getgist', 'googlesheet', 'trello', 'drip', 1850 'sendinblue', 'user_registration', 'automizy', 'telegram', 'salesflare', 'discord', 1851 'cleverreach', 'clicksend', 'zohocrm', 'pipedrive', 'salesforce', 'amocrm', 1852 'onepagecrm', 'airtable', 'mailjet', 'insightly', 'mailster', 'notion' 1853 ]; 1854 1855 foreach ($proIntegrations as $integration) { 1856 if (isset($settings[$integration])) { 1857 foreach ($settings[$integration] as $index => $feed) { 1858 $translatableKeys = [ 1859 'success_message' => 'integration_success_message', 1860 'error_message' => 'integration_error_message', 1861 'confirmation_message' => 'integration_confirmation_message', 1862 'email_subject' => 'integration_email_subject', 1863 'email_body' => 'integration_email_body', 1864 'list_name' => 'integration_list_name', 1865 'tag_name' => 'integration_tag_name', 1866 'note' => 'integration_note', 1867 'description' => 'integration_description' 1868 ]; 1869 1870 foreach ($translatableKeys as $settingKey => $translationKey) { 1871 if (isset($feed['settings'][$settingKey])) { 1872 $extractedStrings["form_{$formId}_feed_{$index}_{$translationKey}"] = $feed['settings'][$settingKey]; 1873 } 1874 } 919 1875 } 920 1876 } … … 1099 2055 } 1100 2056 2057 if (isset($translations["{$fieldName}->prefix_label"])) { 2058 $field['settings']['prefix_label'] = $translations["{$fieldName}->prefix_label"]; 2059 } 2060 2061 if (isset($translations["{$fieldName}->suffix_label"])) { 2062 $field['settings']['suffix_label'] = $translations["{$fieldName}->suffix_label"]; 2063 } 2064 1101 2065 // Update validation messages 1102 2066 if (isset($field['settings']['validation_rules'])) { … … 1105 2069 if (isset($translations[$key])) { 1106 2070 $details['message'] = $translations[$key]; 2071 } 2072 } 2073 } 2074 2075 // Update unique validation message 2076 if (isset($translations["{$fieldName}->unique_validation_message"])) { 2077 $field['settings']['unique_validation_message'] = $translations["{$fieldName}->unique_validation_message"]; 2078 } 2079 2080 // Update inventory/stock messages 2081 if (isset($translations["{$fieldName}->inventory_stockout_message"])) { 2082 $field['settings']['inventory_stockout_message'] = $translations["{$fieldName}->inventory_stockout_message"]; 2083 } 2084 2085 if (isset($translations["{$fieldName}->stock_quantity_label"])) { 2086 $field['settings']['stock_quantity_label'] = $translations["{$fieldName}->stock_quantity_label"]; 2087 } 2088 2089 // Update conditional logic group titles 2090 if (isset($field['settings']['conditional_logics']['condition_groups'])) { 2091 foreach ($field['settings']['conditional_logics']['condition_groups'] as $groupIndex => &$group) { 2092 $key = "{$fieldName}->conditional_logics->condition_groups->{$groupIndex}->title"; 2093 if (isset($translations[$key])) { 2094 $group['title'] = $translations[$key]; 1107 2095 } 1108 2096 } … … 1331 2319 } 1332 2320 break; 2321 2322 case 'save_progress_button': 2323 // Update save progress button messages and email templates 2324 $saveSuccessKey = "{$fieldName}->save_success_message"; 2325 if (isset($translations[$saveSuccessKey])) { 2326 $field['settings']['save_success_message'] = $translations[$saveSuccessKey]; 2327 } 2328 2329 $emailSubjectKey = "{$fieldName}->email_subject"; 2330 if (isset($translations[$emailSubjectKey])) { 2331 $field['settings']['email_subject'] = $translations[$emailSubjectKey]; 2332 } 2333 2334 $emailBodyKey = "{$fieldName}->email_body"; 2335 if (isset($translations[$emailBodyKey])) { 2336 $field['settings']['email_body'] = $translations[$emailBodyKey]; 2337 } 2338 2339 $onCreateSubjectKey = "{$fieldName}->on_create_email_subject"; 2340 if (isset($translations[$onCreateSubjectKey])) { 2341 $field['settings']['on_create_email_subject'] = $translations[$onCreateSubjectKey]; 2342 } 2343 2344 $onCreateBodyKey = "{$fieldName}->on_create_email_body"; 2345 if (isset($translations[$onCreateBodyKey])) { 2346 $field['settings']['on_create_email_body'] = $translations[$onCreateBodyKey]; 2347 } 2348 2349 $onUpdateSubjectKey = "{$fieldName}->on_update_email_subject"; 2350 if (isset($translations[$onUpdateSubjectKey])) { 2351 $field['settings']['on_update_email_subject'] = $translations[$onUpdateSubjectKey]; 2352 } 2353 2354 $onUpdateBodyKey = "{$fieldName}->on_update_email_body"; 2355 if (isset($translations[$onUpdateBodyKey])) { 2356 $field['settings']['on_update_email_body'] = $translations[$onUpdateBodyKey]; 2357 } 2358 break; 2359 2360 case 'ratings': 2361 // Update rating options labels 2362 if (isset($field['options']) && is_array($field['options'])) { 2363 foreach ($field['options'] as $value => $label) { 2364 $ratingKey = "{$fieldName}->Rating Options->{$value}"; 2365 if (isset($translations[$ratingKey])) { 2366 $field['options'][$value] = $translations[$ratingKey]; 2367 } 2368 } 2369 } 2370 break; 2371 2372 case 'select_country': 2373 // Update country options labels 2374 if (isset($field['options']) && is_array($field['options'])) { 2375 foreach ($field['options'] as $value => $label) { 2376 $countryKey = "{$fieldName}->Country Options->{$value}"; 2377 if (isset($translations[$countryKey])) { 2378 $field['options'][$value] = $translations[$countryKey]; 2379 } 2380 } 2381 } 2382 break; 2383 2384 case 'chained_select': 2385 // Update chained select data source headers 2386 if (isset($field['settings']['data_source']['headers']) && is_array($field['settings']['data_source']['headers'])) { 2387 foreach ($field['settings']['data_source']['headers'] as $index => $header) { 2388 $headerKey = "{$fieldName}->data_source->headers->{$index}"; 2389 if (isset($translations[$headerKey])) { 2390 $field['settings']['data_source']['headers'][$index] = $translations[$headerKey]; 2391 } 2392 } 2393 } 2394 break; 2395 2396 case 'recaptcha': 2397 case 'hcaptcha': 2398 case 'turnstile': 2399 // These CAPTCHA fields only have labels that are handled by common field processing 2400 // No additional field-specific translatable content to update 2401 break; 1333 2402 } 1334 2403 } … … 1577 2646 } 1578 2647 1579 public static function getLocales($type = 'date') 1580 { 1581 $locales = [ 1582 'en' => __('English', 'multilingual-forms-fluent-forms-wpml'), 1583 'af' => __('Afrikaans', 'multilingual-forms-fluent-forms-wpml'), 1584 'sq' => __('Albanian', 'multilingual-forms-fluent-forms-wpml'), 1585 'ar-DZ' => __('Algerian Arabic', 'multilingual-forms-fluent-forms-wpml'), 1586 'am' => __('Amharic', 'multilingual-forms-fluent-forms-wpml'), 1587 'ar' => __('Arabic', 'multilingual-forms-fluent-forms-wpml'), 1588 'hy' => __('Armenian', 'multilingual-forms-fluent-forms-wpml'), 1589 'az' => __('Azerbaijani', 'multilingual-forms-fluent-forms-wpml'), 1590 'eu' => __('Basque', 'multilingual-forms-fluent-forms-wpml'), 1591 'be' => __('Belarusian', 'multilingual-forms-fluent-forms-wpml'), 1592 'bn' => __('Bengali', 'multilingual-forms-fluent-forms-wpml'), 1593 'bs' => __('Bosnian', 'multilingual-forms-fluent-forms-wpml'), 1594 'bg' => __('Bulgarian', 'multilingual-forms-fluent-forms-wpml'), 1595 'ca' => __('Catalan', 'multilingual-forms-fluent-forms-wpml'), 1596 'zh-HK' => __('Chinese Hong Kong', 'multilingual-forms-fluent-forms-wpml'), 1597 'zh-CN' => __('Chinese Simplified', 'multilingual-forms-fluent-forms-wpml'), 1598 'zh-TW' => __('Chinese Traditional', 'multilingual-forms-fluent-forms-wpml'), 1599 'hr' => __('Croatian', 'multilingual-forms-fluent-forms-wpml'), 1600 'cs' => __('Czech', 'multilingual-forms-fluent-forms-wpml'), 1601 'da' => __('Danish', 'multilingual-forms-fluent-forms-wpml'), 1602 'nl' => __('Dutch', 'multilingual-forms-fluent-forms-wpml'), 1603 'en-GB' => __('English/UK', 'multilingual-forms-fluent-forms-wpml'), 1604 'eo' => __('Esperanto', 'multilingual-forms-fluent-forms-wpml'), 1605 'et' => __('Estonian', 'multilingual-forms-fluent-forms-wpml'), 1606 'fo' => __('Faroese', 'multilingual-forms-fluent-forms-wpml'), 1607 'fa' => __('Farsi/Persian', 'multilingual-forms-fluent-forms-wpml'), 1608 'fil' => __('Filipino', 'multilingual-forms-fluent-forms-wpml'), 1609 'fi' => __('Finnish', 'multilingual-forms-fluent-forms-wpml'), 1610 'fr' => __('French', 'multilingual-forms-fluent-forms-wpml'), 1611 'fr-CA' => __('French/Canadian', 'multilingual-forms-fluent-forms-wpml'), 1612 'fr-CH' => __('French/Swiss', 'multilingual-forms-fluent-forms-wpml'), 1613 'gl' => __('Galician', 'multilingual-forms-fluent-forms-wpml'), 1614 'ka' => __('Georgian', 'multilingual-forms-fluent-forms-wpml'), 1615 'de' => __('German', 'multilingual-forms-fluent-forms-wpml'), 1616 'de-AT' => __('German/Austria', 'multilingual-forms-fluent-forms-wpml'), 1617 'de-CH' => __('German/Switzerland', 'multilingual-forms-fluent-forms-wpml'), 1618 'el' => __('Greek', 'multilingual-forms-fluent-forms-wpml'), 1619 'gu' => __('Gujarati', 'multilingual-forms-fluent-forms-wpml'), 1620 'he' => __('Hebrew', 'multilingual-forms-fluent-forms-wpml'), 1621 'iw' => __('Hebrew', 'multilingual-forms-fluent-forms-wpml'), 1622 'hi' => __('Hindi', 'multilingual-forms-fluent-forms-wpml'), 1623 'hu' => __('Hungarian', 'multilingual-forms-fluent-forms-wpml'), 1624 'is' => __('Icelandic', 'multilingual-forms-fluent-forms-wpml'), 1625 'id' => __('Indonesian', 'multilingual-forms-fluent-forms-wpml'), 1626 'it' => __('Italian', 'multilingual-forms-fluent-forms-wpml'), 1627 'ja' => __('Japanese', 'multilingual-forms-fluent-forms-wpml'), 1628 'kn' => __('Kannada', 'multilingual-forms-fluent-forms-wpml'), 1629 'kk' => __('Kazakh', 'multilingual-forms-fluent-forms-wpml'), 1630 'km' => __('Khmer', 'multilingual-forms-fluent-forms-wpml'), 1631 'ko' => __('Korean', 'multilingual-forms-fluent-forms-wpml'), 1632 'ky' => __('Kyrgyz', 'multilingual-forms-fluent-forms-wpml'), 1633 'lo' => __('Laothian', 'multilingual-forms-fluent-forms-wpml'), 1634 'lv' => __('Latvian', 'multilingual-forms-fluent-forms-wpml'), 1635 'lt' => __('Lithuanian', 'multilingual-forms-fluent-forms-wpml'), 1636 'lb' => __('Luxembourgish', 'multilingual-forms-fluent-forms-wpml'), 1637 'mk' => __('Macedonian', 'multilingual-forms-fluent-forms-wpml'), 1638 'ml' => __('Malayalam', 'multilingual-forms-fluent-forms-wpml'), 1639 'ms' => __('Malaysian', 'multilingual-forms-fluent-forms-wpml'), 1640 'mr' => __('Marathi', 'multilingual-forms-fluent-forms-wpml'), 1641 'no' => __('Norwegian', 'multilingual-forms-fluent-forms-wpml'), 1642 'nb' => __('Norwegian Bokmål', 'multilingual-forms-fluent-forms-wpml'), 1643 'nn' => __('Norwegian Nynorsk', 'multilingual-forms-fluent-forms-wpml'), 1644 'pl' => __('Polish', 'multilingual-forms-fluent-forms-wpml'), 1645 'pt' => __('Portuguese', 'multilingual-forms-fluent-forms-wpml'), 1646 'pt-BR' => __('Portuguese/Brazilian', 'multilingual-forms-fluent-forms-wpml'), 1647 'pt-PT' => __('Portuguese/Portugal', 'multilingual-forms-fluent-forms-wpml'), 1648 'rm' => __('Romansh', 'multilingual-forms-fluent-forms-wpml'), 1649 'ro' => __('Romanian', 'multilingual-forms-fluent-forms-wpml'), 1650 'ru' => __('Russian', 'multilingual-forms-fluent-forms-wpml'), 1651 'sr' => __('Serbian', 'multilingual-forms-fluent-forms-wpml'), 1652 'sr-SR' => __('Serbian', 'multilingual-forms-fluent-forms-wpml'), 1653 'si' => __('Sinhalese', 'multilingual-forms-fluent-forms-wpml'), 1654 'sk' => __('Slovak', 'multilingual-forms-fluent-forms-wpml'), 1655 'sl' => __('Slovenian', 'multilingual-forms-fluent-forms-wpml'), 1656 'es' => __('Spanish', 'multilingual-forms-fluent-forms-wpml'), 1657 'es-419' => __('Spanish/Latin America', 'multilingual-forms-fluent-forms-wpml'), 1658 'sw' => __('Swahili', 'multilingual-forms-fluent-forms-wpml'), 1659 'sv' => __('Swedish', 'multilingual-forms-fluent-forms-wpml'), 1660 'ta' => __('Tamil', 'multilingual-forms-fluent-forms-wpml'), 1661 'te' => __('Telugu', 'multilingual-forms-fluent-forms-wpml'), 1662 'th' => __('Thai', 'multilingual-forms-fluent-forms-wpml'), 1663 'tj' => __('Tajiki', 'multilingual-forms-fluent-forms-wpml'), 1664 'tr' => __('Turkish', 'multilingual-forms-fluent-forms-wpml'), 1665 'uk' => __('Ukrainian', 'multilingual-forms-fluent-forms-wpml'), 1666 'ur' => __('Urdu', 'multilingual-forms-fluent-forms-wpml'), 1667 'vi' => __('Vietnamese', 'multilingual-forms-fluent-forms-wpml'), 1668 'cy-GB' => __('Welsh', 'multilingual-forms-fluent-forms-wpml'), 1669 'zu' => __('Zulu', 'multilingual-forms-fluent-forms-wpml'), 2648 2649 /** 2650 * Get supported reCAPTCHA language codes 2651 * Based on: https://developers.google.com/recaptcha/docs/language 2652 */ 2653 public static function getRecaptchaLocales() 2654 { 2655 return [ 2656 'ar' => 'ar', // Arabic 2657 'af' => 'af', // Afrikaans 2658 'am' => 'am', // Amharic 2659 'hy' => 'hy', // Armenian 2660 'az' => 'az', // Azerbaijani 2661 'eu' => 'eu', // Basque 2662 'bn' => 'bn', // Bengali 2663 'bg' => 'bg', // Bulgarian 2664 'ca' => 'ca', // Catalan 2665 'zh-HK' => 'zh-HK', // Chinese (Hong Kong) 2666 'zh-CN' => 'zh-CN', // Chinese (Simplified) 2667 'zh-TW' => 'zh-TW', // Chinese (Traditional) 2668 'hr' => 'hr', // Croatian 2669 'cs' => 'cs', // Czech 2670 'da' => 'da', // Danish 2671 'nl' => 'nl', // Dutch 2672 'en' => 'en', // English (US) 2673 'en-GB' => 'en-GB', // English (UK) 2674 'et' => 'et', // Estonian 2675 'fil' => 'fil', // Filipino 2676 'fi' => 'fi', // Finnish 2677 'fr' => 'fr', // French 2678 'fr-CA' => 'fr-CA', // French (Canadian) 2679 'gl' => 'gl', // Galician 2680 'ka' => 'ka', // Georgian 2681 'de' => 'de', // German 2682 'de-AT' => 'de-AT', // German (Austria) 2683 'de-CH' => 'de-CH', // German (Switzerland) 2684 'el' => 'el', // Greek 2685 'gu' => 'gu', // Gujarati 2686 'iw' => 'he', // Hebrew (WPML uses 'iw', reCAPTCHA uses 'he') 2687 'he' => 'he', // Hebrew 2688 'hi' => 'hi', // Hindi 2689 'hu' => 'hu', // Hungarian 2690 'is' => 'is', // Icelandic 2691 'id' => 'id', // Indonesian 2692 'it' => 'it', // Italian 2693 'ja' => 'ja', // Japanese 2694 'kn' => 'kn', // Kannada 2695 'ko' => 'ko', // Korean 2696 'lo' => 'lo', // Laothian 2697 'lv' => 'lv', // Latvian 2698 'lt' => 'lt', // Lithuanian 2699 'ms' => 'ms', // Malay 2700 'ml' => 'ml', // Malayalam 2701 'mr' => 'mr', // Marathi 2702 'mn' => 'mn', // Mongolian 2703 'no' => 'no', // Norwegian 2704 'fa' => 'fa', // Persian 2705 'pl' => 'pl', // Polish 2706 'pt' => 'pt', // Portuguese 2707 'pt-BR' => 'pt-BR', // Portuguese (Brazil) 2708 'pt-PT' => 'pt-PT', // Portuguese (Portugal) 2709 'ro' => 'ro', // Romanian 2710 'ru' => 'ru', // Russian 2711 'sr' => 'sr', // Serbian 2712 'si' => 'si', // Sinhalese 2713 'sk' => 'sk', // Slovak 2714 'sl' => 'sl', // Slovenian 2715 'es' => 'es', // Spanish 2716 'es-419' => 'es-419', // Spanish (Latin America) 2717 'sw' => 'sw', // Swahili 2718 'sv' => 'sv', // Swedish 2719 'ta' => 'ta', // Tamil 2720 'te' => 'te', // Telugu 2721 'th' => 'th', // Thai 2722 'tr' => 'tr', // Turkish 2723 'uk' => 'uk', // Ukrainian 2724 'ur' => 'ur', // Urdu 2725 'vi' => 'vi', // Vietnamese 2726 'zu' => 'zu', // Zulu 1670 2727 ]; 1671 1672 $unset = []; 1673 1674 if ($type === 'captcha') { 1675 $unset = [ 1676 'sq', 1677 'bs', 1678 'eo', 1679 'fo', 1680 'fr-CH', 1681 'sr-SR', 1682 'ar-DZ', 1683 'be', 1684 'cy-GB', 1685 'kk', 1686 'km', 1687 'ky', 1688 'lb', 1689 'mk', 1690 'nb', 1691 'nn', 1692 'rm', 1693 'tj' 1694 ]; 1695 } elseif ($type === 'date') { 1696 $unset = [ 1697 'fil', 1698 'fr-CA', 1699 'de-AT', 1700 'de-CH', 1701 'iw', 1702 'hi', 1703 'pt', 1704 'pt-PT', 1705 'es-419', 1706 'mr', 1707 'lo', 1708 'kn', 1709 'si', 1710 'gu', 1711 'bn', 1712 'zu', 1713 'ur', 1714 'te', 1715 'sw', 1716 'am' 1717 ]; 1718 } 1719 1720 return array_diff_key($locales, array_flip($unset)); 2728 } 2729 2730 /** 2731 * Get supported hCaptcha language codes 2732 * Based on: https://docs.hcaptcha.com/languages/ 2733 */ 2734 public static function getHcaptchaLocales() 2735 { 2736 return [ 2737 'af' => 'af', // Afrikaans 2738 'sq' => 'sq', // Albanian 2739 'am' => 'am', // Amharic 2740 'ar' => 'ar', // Arabic 2741 'hy' => 'hy', // Armenian 2742 'az' => 'az', // Azerbaijani 2743 'eu' => 'eu', // Basque 2744 'be' => 'be', // Belarusian 2745 'bn' => 'bn', // Bengali 2746 'bg' => 'bg', // Bulgarian 2747 'ca' => 'ca', // Catalan 2748 'zh-CN' => 'zh-CN', // Chinese (Simplified) 2749 'zh-TW' => 'zh-TW', // Chinese (Traditional) 2750 'hr' => 'hr', // Croatian 2751 'cs' => 'cs', // Czech 2752 'da' => 'da', // Danish 2753 'nl' => 'nl', // Dutch 2754 'en' => 'en', // English 2755 'et' => 'et', // Estonian 2756 'fil' => 'fil', // Filipino 2757 'fi' => 'fi', // Finnish 2758 'fr' => 'fr', // French 2759 'gl' => 'gl', // Galician 2760 'ka' => 'ka', // Georgian 2761 'de' => 'de', // German 2762 'el' => 'el', // Greek 2763 'gu' => 'gu', // Gujarati 2764 'iw' => 'he', // Hebrew (WPML uses 'iw', hCaptcha uses 'he') 2765 'he' => 'he', // Hebrew 2766 'hi' => 'hi', // Hindi 2767 'hu' => 'hu', // Hungarian 2768 'is' => 'is', // Icelandic 2769 'id' => 'id', // Indonesian 2770 'it' => 'it', // Italian 2771 'ja' => 'ja', // Japanese 2772 'kn' => 'kn', // Kannada 2773 'kk' => 'kk', // Kazakh 2774 'km' => 'km', // Khmer 2775 'ko' => 'ko', // Korean 2776 'ky' => 'ky', // Kyrgyz 2777 'lo' => 'lo', // Lao 2778 'lv' => 'lv', // Latvian 2779 'lt' => 'lt', // Lithuanian 2780 'mk' => 'mk', // Macedonian 2781 'ms' => 'ms', // Malay 2782 'ml' => 'ml', // Malayalam 2783 'mt' => 'mt', // Maltese 2784 'mn' => 'mn', // Mongolian 2785 'my' => 'my', // Myanmar (Burmese) 2786 'ne' => 'ne', // Nepali 2787 'no' => 'no', // Norwegian 2788 'fa' => 'fa', // Persian 2789 'pl' => 'pl', // Polish 2790 'pt' => 'pt', // Portuguese 2791 'pt-BR' => 'pt-BR', // Portuguese (Brazil) 2792 'ro' => 'ro', // Romanian 2793 'ru' => 'ru', // Russian 2794 'sr' => 'sr', // Serbian 2795 'si' => 'si', // Sinhala 2796 'sk' => 'sk', // Slovak 2797 'sl' => 'sl', // Slovenian 2798 'es' => 'es', // Spanish 2799 'sw' => 'sw', // Swahili 2800 'sv' => 'sv', // Swedish 2801 'ta' => 'ta', // Tamil 2802 'te' => 'te', // Telugu 2803 'th' => 'th', // Thai 2804 'tr' => 'tr', // Turkish 2805 'uk' => 'uk', // Ukrainian 2806 'ur' => 'ur', // Urdu 2807 'uz' => 'uz', // Uzbek 2808 'vi' => 'vi', // Vietnamese 2809 'zu' => 'zu', // Zulu 2810 ]; 2811 } 2812 2813 /** 2814 * Get supported Turnstile language codes 2815 * Based on: https://developers.cloudflare.com/turnstile/reference/supported-languages/ 2816 */ 2817 public static function getTurnstileLocales() 2818 { 2819 return [ 2820 'ar-EG' => 'ar-EG', // Arabic (Egypt) 2821 'de' => 'de', // German 2822 'en' => 'en', // English 2823 'es' => 'es', // Spanish 2824 'fa' => 'fa', // Persian 2825 'fr' => 'fr', // French 2826 'id' => 'id', // Indonesian 2827 'it' => 'it', // Italian 2828 'ja' => 'ja', // Japanese 2829 'ko' => 'ko', // Korean 2830 'nl' => 'nl', // Dutch 2831 'pl' => 'pl', // Polish 2832 'pt-BR' => 'pt-BR', // Portuguese (Brazil) 2833 'ru' => 'ru', // Russian 2834 'tr' => 'tr', // Turkish 2835 'zh-CN' => 'zh-CN', // Chinese (Simplified) 2836 'zh-TW' => 'zh-TW', // Chinese (Traditional) 2837 'ar' => 'ar-EG', // Arabic -> Arabic (Egypt) 2838 'pt' => 'pt-BR', // Portuguese -> Portuguese (Brazil) 2839 'zh' => 'zh-CN', // Chinese -> Chinese (Simplified) 2840 ]; 2841 } 2842 2843 public function translateEmailTemplateHeader($header, $form, $notification) 2844 { 2845 if (!$this->isWpmlEnabledOnForm($form->id)) { 2846 return $header; 2847 } 2848 2849 $package = $this->getFormPackage($form); 2850 return apply_filters('wpml_translate_string', $header, "form_{$form->id}_email_template_header", $package); 2851 } 2852 2853 public function translateEmailTemplateFooter($footer, $form, $notification) 2854 { 2855 if (!$this->isWpmlEnabledOnForm($form->id)) { 2856 return $footer; 2857 } 2858 2859 $package = $this->getFormPackage($form); 2860 return apply_filters('wpml_translate_string', $footer, "form_{$form->id}_email_template_footer", $package); 2861 } 2862 2863 public function translateEmailSubjectLine($subject, $form, $notification) 2864 { 2865 if (!$this->isWpmlEnabledOnForm($form->id)) { 2866 return $subject; 2867 } 2868 2869 $package = $this->getFormPackage($form); 2870 return apply_filters('wpml_translate_string', $subject, "form_{$form->id}_email_subject_line", $package); 2871 } 2872 2873 public function translateSubscriptionMessage($message, $formData, $form) 2874 { 2875 if (!$this->isWpmlEnabledOnForm($form->id)) { 2876 return $message; 2877 } 2878 2879 $package = $this->getFormPackage($form); 2880 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_subscription_confirmation_message", $package); 2881 } 2882 2883 public function translateRecurringPaymentMessage($message, $formData, $form) 2884 { 2885 if (!$this->isWpmlEnabledOnForm($form->id)) { 2886 return $message; 2887 } 2888 2889 $package = $this->getFormPackage($form); 2890 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_recurring_payment_message", $package); 2891 } 2892 2893 public function translateSubmissionMessageParse($message, $insertId, $formData, $form) 2894 { 2895 if (!$this->isWpmlEnabledOnForm($form->id)) { 2896 return $message; 2897 } 2898 2899 $package = $this->getFormPackage($form); 2900 return apply_filters('wpml_translate_string', $message, "form_{$form->id}_submission_message_parse", $package); 2901 } 2902 2903 public function translateFormSubmissionMessages($messages, $form) 2904 { 2905 if (!$this->isWpmlEnabledOnForm($form->id)) { 2906 return $messages; 2907 } 2908 2909 $package = $this->getFormPackage($form); 2910 2911 $translatableKeys = [ 2912 'file_upload_in_progress' => 'file_upload_in_progress_message', 2913 'javascript_handler_failed' => 'javascript_handler_failed_message' 2914 ]; 2915 2916 foreach ($translatableKeys as $key => $translationKey) { 2917 if (isset($messages[$key])) { 2918 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 2919 } 2920 } 2921 2922 return $messages; 2923 } 2924 2925 public function translatePaymentHandlerMessages($messages, $form) 2926 { 2927 if (!$this->isWpmlEnabledOnForm($form->id)) { 2928 return $messages; 2929 } 2930 2931 $package = $this->getFormPackage($form); 2932 2933 $translatableKeys = [ 2934 'stock_out_message' => 'payment_stock_out_message', 2935 'item_label' => 'payment_item_label', 2936 'price_label' => 'payment_price_label', 2937 'qty_label' => 'payment_qty_label', 2938 'line_total_label' => 'payment_line_total_label', 2939 'sub_total_label' => 'payment_sub_total_label', 2940 'discount_label' => 'payment_discount_label', 2941 'total_label' => 'payment_total_label', 2942 'signup_fee_label' => 'payment_signup_fee_label', 2943 'trial_label' => 'payment_trial_label', 2944 'processing_text' => 'payment_processing_text', 2945 'confirming_text' => 'payment_confirming_text' 2946 ]; 2947 2948 foreach ($translatableKeys as $key => $translationKey) { 2949 if (isset($messages[$key])) { 2950 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 2951 } 2952 } 2953 2954 return $messages; 2955 } 2956 2957 public function translateFormSaveProgressMessages($messages, $form) 2958 { 2959 if (!$this->isWpmlEnabledOnForm($form->id)) { 2960 return $messages; 2961 } 2962 2963 $package = $this->getFormPackage($form); 2964 2965 $translatableKeys = [ 2966 'copy_button' => 'save_progress_copy_button', 2967 'email_button' => 'save_progress_email_button', 2968 'email_placeholder' => 'save_progress_email_placeholder', 2969 'copy_success' => 'save_progress_copy_success' 2970 ]; 2971 2972 foreach ($translatableKeys as $key => $translationKey) { 2973 if (isset($messages[$key])) { 2974 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 2975 } 2976 } 2977 2978 return $messages; 2979 } 2980 2981 public function translateAddressAutocompleteMessages($messages, $form) 2982 { 2983 if (!$this->isWpmlEnabledOnForm($form->id)) { 2984 return $messages; 2985 } 2986 2987 $package = $this->getFormPackage($form); 2988 2989 $translatableKeys = [ 2990 'please_wait' => 'address_autocomplete_please_wait', 2991 'location_not_determined' => 'address_autocomplete_location_not_determined', 2992 'address_fetch_failed' => 'address_autocomplete_address_fetch_failed', 2993 'geolocation_failed' => 'address_autocomplete_geolocation_failed', 2994 'geolocation_not_supported' => 'address_autocomplete_geolocation_not_supported' 2995 ]; 2996 2997 foreach ($translatableKeys as $key => $translationKey) { 2998 if (isset($messages[$key])) { 2999 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 3000 } 3001 } 3002 3003 return $messages; 3004 } 3005 3006 public function translatePaymentGatewayMessages($messages, $form) 3007 { 3008 if (!$this->isWpmlEnabledOnForm($form->id)) { 3009 return $messages; 3010 } 3011 3012 $package = $this->getFormPackage($form); 3013 3014 $translatableKeys = [ 3015 'request_failed' => 'payment_gateway_request_failed', 3016 'payment_failed' => 'payment_gateway_payment_failed', 3017 'no_method_found' => 'payment_gateway_no_method_found', 3018 'processing_text' => 'payment_gateway_processing_text' 3019 ]; 3020 3021 foreach ($translatableKeys as $key => $translationKey) { 3022 if (isset($messages[$key])) { 3023 $messages[$key] = apply_filters('wpml_translate_string', $messages[$key], "form_{$form->id}_{$translationKey}", $package); 3024 } 3025 } 3026 3027 return $messages; 1721 3028 } 1722 3029 }
Note: See TracChangeset
for help on using the changeset viewer.