Hacks: Language problem with comments
Posted by: ZirafkaOn 2009/11/22 18:30:00 5291 readsThe Websites are quite often criticized that the authors of programs or other systems do not consider a different language than their own. So different numbers are displayed correctly in the original language, but in other languages they appear strange.
For example, if the original module is able to distinguish only one or more comments, it's a problem, as the translation results in: "Pocet komentaru: 3" instead of the correct "3 komentare" (Examples are given for the Czech language).
For my server, I adjusted the News module as follows:
File language/YOUR_LANGUAGE/main.php:
define("_NW_NUMCOMMENTS","%s komentare");
change to:
define("_NW_NUMCOMMENTS2","%s komentare"); // 2 - 4 comments
define("_NW_NUMCOMMENTS5","%s komentaru"); // more than 4 comments
File class/class.newsstory.php:
if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule'])
{
$ccount = $this->comments();
$morelink .= 'href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
$morelink2 = 'href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
if ( $ccount == 0 )
{
$morelink .= '">'._NW_COMMENTS.'';
}
else
{
if ( $fullcount < 1 )
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_READMORE.' | '.$morelink2.'">'._NW_ONECOMMENT.'';
}
else
{
$morelink .= '">'._NW_READMORE.' | '.$morelink2.'">';
$morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
$morelink .= '';
}
}
else
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_ONECOMMENT.'';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
$morelink .= '';
}
}
}
}
change to:
if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule'])
{
$ccount = $this->comments();
$morelink .= 'href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
$morelink2 = 'href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
if ( $ccount == 0 )
{
$morelink .= '">'._NW_COMMENTS.'';
}
else
{
if ( $fullcount < 1 )
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_READMORE.' | '.$morelink2.'">'._NW_ONECOMMENT.'';
}
else
{
if (( $ccount >1 ) && ( $ccount <5))
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS2, $ccount);
$morelink .= '';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS5, $ccount);
$morelink .= '';
}
}
}
else
{
if ( $ccount == 1 ) {
$morelink .= '">'._NW_ONECOMMENT.'';
}
else
{
if (( $ccount >1 ) && ( $ccount <5))
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS2, $ccount);
$morelink .= '';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS5, $ccount);
$morelink .= '';
}
}
}
}
}
Modification work will begin immediately, but if you have enabled the cache, it needs to first be erased, otherwise the change will take effect after the flush.
This hack is tested on Xoops 2.4.1 with News module version 1.63
And as always, finally talk about modifying the system: before any treatment can make backup copies of the original files. You never know what can go wrong where.
And that's all