Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem: Translate WordPress Simple Survey Options

Solution: The client was trying to translate custom strings of Simple Survey plugin. This plugin is not compatible with WPML and using separate tables for recording Survey options and answers in Database. It works after they have registered & translated the custom strings using *wpml_register_single_string* and *wpml_translate_single_string* APIs.

Relevant Documentation: https://wpml.org/wpml-hook/wpml_register_single_string/

https://wpml.org/wpml-hook/wpml_translate_single_string/

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 5 replies, has 2 voices.

Last updated by Kristof 3 years, 9 months ago.

Assigned support staff: Bigul.

Author Posts
December 6, 2017 at 2:54 pm #1450899

Kristof

We have a highly modded WordPress Simple Survey plugin where questions, results and options need to be translated (see previous ticket: https://wpml.org/forums/topic/translate-wordpress-simple-survey-questionsresults/).
Question/Answers are ready but after a quiz is completed, results can be emailed to the admin/user. This email is configured via the Options of the plugin (see screenshot). However, we have no clue how to translate this Auto-Respond Email Content & Auto-Response Email Subject Line as the content does not appear in the String Translation tables.

Screenshot_7.png
December 8, 2017 at 9:04 am #1452588

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Kristof,

Welcome to the WPML support forum. I will do my best to help you to resolve these issues.

In some cases, it is possible that those strings have been recognized but not associated yet to the String Translation panel for the translation. Please try the following steps after a backup and let me know your feedback.

1) Visit WPML>>String Translation
2) Click on the blue link at the bottom of the page: "Translate texts in admin screens »"
3) Look for an option similar to "theme_mod", or something like that. Here you should find all strings associated with your theme/plugins options.
4) Check the checkbox for your strings of interest.
5) Click on the button "Apply"(at the bottom of the page)
6) Now, all your selected strings should appear in the String Translation panel and you can translate those strings

Please check the following tutorial for more details.

https://wpml.org/documentation/getting-started-guide/translating-theme-options/

If you are still having the issues, please share me the login information(after a full site backup) and the steps to access this Mail option screen.

--
Thanks!

Bigul

December 11, 2017 at 3:01 pm #1454463

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Kristof,

Thank you for the login information. The Auto-Respond Email Content & Auto-Response Email Subject Line are stored in *wp_wpss_quizzes_30* table, so you have to use *wpml_register_single_string* and *wpml_translate_single_string* hooks to register and translate it. Like we did in the previous cases. Becuase there is no other option to translate it.

You have to do the changes in the following files. Please try it after a full site backup and let me know your feedback.

Make the following change in Line 8 of *wordpress-simple-survey/mailers/view.quiz_taker_email_content.php*

From

$msg = wpss_wysiwyg_output( $result->quiz->user_email_content );

To

$msg = wpss_wysiwyg_output( $result->quiz->user_email_content );
//register the string for translation
do_action( 'wpml_register_single_string', 'survey-mail-msg', 'mail-msg', $msg );
  
//display original string or translated string
$msg = apply_filters( 'wpml_translate_single_string', $msg, 'survey-mail-msg', 'mail-msg' );

Make the following change in Line 385 of *wordpress-simple-survey/lib/class.result.php*

From

$subject = $this->quiz->user_email_subject;

To

$subject = $this->quiz->user_email_subject;
//register the string for translation
do_action( 'wpml_register_single_string', 'survey-mail-subject', 'mail-subject', $subject );
  
//display original string or translated string
$subject = apply_filters( 'wpml_translate_single_string', $subject, 'survey-mail-subject', 'mail-subject' );

You have to send a test mail first to register these strings for translation.

--
Thanks!

Bigul

December 15, 2017 at 10:31 am #1458747

Kristof

Hi, your code worked perfectly for the Mail Message and the Mail Subject.

Unfortunately we found yet another, hopefully the last, string that we cannot translate, the Quiz Title "Het Overloop-effect" on hidden link.
It must be either "wpss[title]" or "$quiz->title;" but we do not know which instance/php we need to edit.

December 15, 2017 at 6:59 pm #1459286

Bigul
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hi Kristof,

Please make the following change on Line 20 of *wordpress-simple-survey/views/quiz/view.quiz.php* after a backup and let me know your feedback.

From

 if( $quiz->show_title ){
      $o .=   '<h2 class="wpss_title">' . $quiz->title . '</h2>';
 }

To

if( $quiz->show_title ){

      $quiz_title = $quiz->title;
      //register the string for translation
      do_action( 'wpml_register_single_string', 'survey-quiz-title', 'quiz-title', $quiz_title );
   
      //display original string or translated string
      $quiz_title = apply_filters( 'wpml_translate_single_string', $quiz_title, 'survey-quiz-title', 'quiz-title' );

      $o .=   '<h2 class="wpss_title">' . $quiz_title . '</h2>';
 }

--
Thanks!

Bigul

December 18, 2017 at 8:52 am #1460051

Kristof

Thank you so much for your patience and your persistence. This has been a hell of a plugin to translate 🙁