Your comment forms in French or any other languages Print

Version française disponible ici

The comment system included in Textpattern seems to divide the community: some refuse it on the grounds that TXP is primarily a CMS (without this necessity) on the other hand it seems that other wants to enhance it (Stef Dawson is working on a specific plugin). Nevertheless, the use of comments in a multilingual site is hampered by the inability to translate the labels of input fields.

Until a formal integration into Textpattern here is a solution by hacking the file /textpattern/publish/comment.php.

Open this file hopelessly monolingual ;) then see the line #55 to change it like this:

  1. function commentForm($id, $atts=NULL)
  2. {
  3. global $prefs;
  4. extract($prefs);
  5. extract(lAtts(array(
  6. 'isize' => '25',
  7. 'msgrows' => '5',
  8. 'msgcols' => '25',
  9. 'msgstyle' => '',
  10. 'form' => 'comment_form',
  11. 'previewlabel' => gTxt('preview'),
  12. 'submitlabel' => gTxt('submit'),
  13. 'rememberlabel' => gTxt('remember'),
  14. 'forgetlabel' => gTxt('forget')
  15. ),$atts, 0));

This change begins at the line above numbered #13 by adding some few new attributes:

  • previewlabel
  • submitlabel
  • rememberlabel
  • forgetlabel

These attributes include by default the titles of the current language of your TXP administration interface. That are injected from the #160 into the same file:

  1. // by default, the submit button is visible but disabled
  2. $comment_submit_button = fInput('submit', 'submit', $submitlabel, 'button disabled', '', '', '', '', 'txpCommentSubmit', true);
  3. // if all fields checkout, the submit button is active/clickable
  4. if ($preview) {
  5. $comment_submit_button = fInput('submit', 'submit', $submitlabel, 'button', '', '', '', '', 'txpCommentSubmit', false);
  6. }
  7. if ($checkbox_type = = 'forget')
  8. {
  9. // inhibit default remember
  10. if ($forget == 1)
  11. {
  12. destroyCookies();
  13. }
  14. $checkbox = checkbox('forget', 1, $forget, '', 'forget').' '.tag($forgetlabel, 'label', ' for="forget"');
  15. }
  16. else
  17. {
  18. // inhibit default remember
  19. if ($remember != 1)
  20. {
  21. destroyCookies();
  22. }
  23. $checkbox = checkbox('remember', 1, $remember, '', 'remember').' '.tag($rememberlabel, 'label', ' for="remember"');
  24. }
  25. $checkbox .= ' '.hInput('checkbox_type', $checkbox_type);
  26. $vals = array(
  27. 'comment_name_input' => fInput('text', 'name', htmlspecialchars($name), 'comment_name_input'.($namewarn ? ' comments_error' : ''), '', '', $isize, '', 'name'),
  28. 'comment_email_input' => fInput('email', 'email', htmlspecialchars($email), 'comment_email_input'.($emailwarn ? ' comments_error' : ''), '', '', $isize, '', 'email'),
  29. 'comment_web_input' => fInput('url', 'web', htmlspecialchars($web) , 'comment_web_input', '', '', $isize, '', 'web'),
  30. 'comment_message_input' => $textarea.'<!-- plugin-place-holder -->',
  31. 'comment_remember' => $checkbox,
  32. 'comment_preview' => fInput('submit', 'preview', $previewlabel, 'button', '', '', '', '', 'txpCommentPreview', false),
  33. 'comment_submit' => $comment_submit_button
  34. );

Here is, as it should occur, the final file and the checksum code 1592bbd8618aa51745185f4fe9465fcf has changed into /textpattern/checksum.txt file in order to benefit of the security system features.

Now you are the masters of the world, since you can build your multilingual comment modules, i.e. a module named “comment_form” (“comment” type):

  1. <txp:hide>
  2. ** comment.php file hacked: previewlabel, submitlabel, rememberlabel, forgetlabel attributes added for multi-language translations support
  3. </txp:hide>
  4. <txp:comments_form previewlabel="Aperçu" submitlabel="Envoyer" rememberlabel="Mémoriser mes informations" forgetlabel="Supprimer mes informations" />

That is exactly what’s in use in this txp-fr.net website!

Now you have no excuse to integrate the French language into your websites, or any other language ;)

Note: This feature is added in TXP 4.5.0

Published on | Updated on by Patrick LEFÈVRE.

Related Articles

Hide your sections for non admin users - Publié le 2011.09.28 By Patrick LEFÈVRE.
Display a page on your website for known referrers - Publié le 2012.02.09 By Patrick LEFÈVRE.
Control you blank pages - Publié le 2011.12.22 By Patrick LEFÈVRE.
Split your links list into columns - Publié le 2011.12.14 By Patrick LEFÈVRE.
Access to all article archives

» Previous Article» Next Article
txp:fr supports Textpattern ;·) Textpattern CMS

Need Help? Post your question on Entr'Aide txp:fr website