Language problem with comments



2009-11-22

The 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 .= '<a
href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
$morelink2 = '<a
href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';

if ( $ccount == 0 )
{
$morelink .= '">'._NW_COMMENTS.'</a>';
}
else
{
if ( $fullcount < 1 )
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">'._NW_ONECOMMENT.'</a>';
}
else
{
$morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">';
$morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
$morelink .= '</a>';
}
}
else
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_ONECOMMENT.'</a>';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS, $ccount);
$morelink .= '</a>';
}
}
}
}


change to:


if (XOOPS_COMMENT_APPROVENONE != $xoopsModuleConfig['com_rule'])
{
$ccount = $this->comments();
$morelink .= '<a
href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';
$morelink2 = '<a
href="'.XOOPS_URL.'/modules/news/article.php?storyid='.$this->storyid().'';

if ( $ccount == 0 )
{
$morelink .= '">'._NW_COMMENTS.'</a>';
}
else
{
if ( $fullcount < 1 )
{
if ( $ccount == 1 )
{
$morelink .= '">'._NW_READMORE.'</a> | '.$morelink2.'">'._NW_ONECOMMENT.'</a>';
}
else
{
if (( $ccount >1 ) && ( $ccount <5))
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS2, $ccount);
$morelink .= '</a>';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS5, $ccount);
$morelink .= '</a>';
}
}
}
else
{
if ( $ccount == 1 ) {
$morelink .= '">'._NW_ONECOMMENT.'</a>';
}
else
{
if (( $ccount >1 ) && ( $ccount <5))
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS2, $ccount);
$morelink .= '</a>';
}
else
{
$morelink .= '">';
$morelink .= sprintf(_NW_NUMCOMMENTS5, $ccount);
$morelink .= '</a>';
}
}
}
}
}


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

Postar um comentário