Your comment forms in French or any other languages Print
By Patrick LEFÈVRE published on 2011 12 24
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:
function commentForm($id, $atts=NULL)
{
global $prefs;
extract($prefs);
extract(lAtts(array(
'isize' => '25',
'msgrows' => '5',
'msgcols' => '25',
'msgstyle' => '',
'form' => 'comment_form',
'previewlabel' => gTxt('preview'),
'submitlabel' => gTxt('submit'),
'rememberlabel' => gTxt('remember'),
'forgetlabel' => gTxt('forget')
),$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:
// by default, the submit button is visible but disabled
$comment_submit_button = fInput('submit', 'submit', $submitlabel, 'button disabled', '', '', '', '', 'txpCommentSubmit', true);
// if all fields checkout, the submit button is active/clickable
if ($preview) {
$comment_submit_button = fInput('submit', 'submit', $submitlabel, 'button', '', '', '', '', 'txpCommentSubmit', false);
}
if ($checkbox_type = = 'forget')
{
// inhibit default remember
if ($forget == 1)
{
destroyCookies();
}
$checkbox = checkbox('forget', 1, $forget, '', 'forget').' '.tag($forgetlabel, 'label', ' for="forget"');
}
else
{
// inhibit default remember
if ($remember != 1)
{
destroyCookies();
}
$checkbox = checkbox('remember', 1, $remember, '', 'remember').' '.tag($rememberlabel, 'label', ' for="remember"');
}
$checkbox .= ' '.hInput('checkbox_type', $checkbox_type);
$vals = array(
'comment_name_input' => fInput('text', 'name', htmlspecialchars($name), 'comment_name_input'.($namewarn ? ' comments_error' : ''), '', '', $isize, '', 'name'),
'comment_email_input' => fInput('email', 'email', htmlspecialchars($email), 'comment_email_input'.($emailwarn ? ' comments_error' : ''), '', '', $isize, '', 'email'),
'comment_web_input' => fInput('url', 'web', htmlspecialchars($web) , 'comment_web_input', '', '', $isize, '', 'web'),
'comment_message_input' => $textarea.'<!-- plugin-place-holder -->',
'comment_remember' => $checkbox,
'comment_preview' => fInput('submit', 'preview', $previewlabel, 'button', '', '', '', '', 'txpCommentPreview', false),
'comment_submit' => $comment_submit_button
);
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):
<txp:hide>
** comment.php file hacked: previewlabel, submitlabel, rememberlabel, forgetlabel attributes added for multi-language translations support
</txp:hide>
<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
Related Articles
Split your links list into columns - Publié le 2011.12.14 By Patrick LEFÈVRE.
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.
Access to all article archives