The Joomla! Forum ™






Post new topic Reply to topic  [ 9 posts ] 
Author Message
PostPosted: Tue Sep 22, 2009 5:48 pm 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Jul 18, 2008 2:28 pm
Posts: 786
Location: Dinajpur, Bangladesh
I need the word "Tags" in SearchTag plugin translated. No language file, No support by the developer.

Pls help.

Code:
<?php
/**
* @version $Id: plgContentBookMarks.php 1.5
* @copyright Joe Guo
* @license GNU/GPLv2,
* @author Joe Guo - http://www.ctoptravel.com
*/
defined( '_JEXEC' ) or  die('Restricted access');
jimport( 'joomla.event.plugin' );


class plgContentSearchTag extends JPlugin
{
   function plgContentSearchTag( &$subject, $params )
      {
         parent::__construct( $subject, $params );   
      }   
   
   function onPrepareContent( &$article, &$params )
   {   
     if ((JRequest :: getVar('view')) == 'article'){
       
        $links = '';
        $keys = explode( ',', $article->metakey );
        foreach ($keys as $key) {
        $key = trim( $key );
        if($key==''){
            continue;
        }
        if ($key) {
             $searchphrase=$this->param('searchphrase');
             if(!$searchphrase){
                $searchphrase='all';             
             }
             $link="index.php?option=com_search&areas[]=content&searchphrase=".$searchphrase."&searchword=";
             $link.=urlencode($key);
             $link=JRoute::_($link);
             $links.="<a href='".$link."'>".$key."</a>&nbsp;&nbsp;";
        }
      }
      if ($links!=""){
        $cssStyle=$this->param('cssStyle');
        if($cssStyle){
           $article->text.="<br><br><div class='".$cssStyle."'>Tags: ". $links ."</div>";
        }else{
           $align=$this->param('align');
           $alignStyle="";
           if($align!='none'){
             $alignStyle=" align='".$align."'";
           }
           $article->text.="<br><br><div ".$alignStyle." style='background-color:#efefef';>Tags: ". $links ."</div>";
        }
      }
     
    }//end if JRequest
     return true;
   }
   
   function param($name){
      static $plugin,$pluginParams;
      if (!isset( $plugin )){
          $plugin =& JPluginHelper::getPlugin('content', 'SearchTag');
        $pluginParams = new JParameter( $plugin->params );
      }
      return $pluginParams->get($name);
 }
   
}
?>

_________________
http://Dinajpur.NET - My home district portal < not a Bangla joomla demo site ;)
http://RangpurBD.com - Rangpur Portal


Last edited by almamun on Wed Sep 23, 2009 10:05 am, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 7:37 am 
User avatar
Joomla! Exemplar
Joomla! Exemplar

Joined: Thu Aug 18, 2005 9:58 am
Posts: 9893
Location: Hillerød - Denmark
Hi almamun,

Looks like the developer of this plugin didnt provide support of translating their extension, as there are no language ini-files included and there are hardcoded strings in the code.

So you would have to change the 'Tags' string directly in the code, or change in in the code in a way to allow the string to be translated by replacing the 'Tags' string with a JText::_( 'Tags') and a corresponding en-GB.plg_content_SearchTag.ini + a bn-BD.plg_content_SearchTag.ini both holding the translateable string: (en-GB) Tags=Tags and (bn-BD) Tags=your translation here

How you want to fix it depends whether you need just one or more languages at your site. If its just a one language site, you could go for the easy fix of just translating the two hardcoded strings in the code, marked in bold below:
Quote:
if ($links!=""){
$cssStyle=$this->param('cssStyle');
if($cssStyle){
$article->text.="<br><br><div class='".$cssStyle."'>Tags: ". $links ."</div>";
}else{
$align=$this->param('align');
$alignStyle="";
if($align!='none'){
$alignStyle=" align='".$align."'";
}
$article->text.="<br><br><div ".$alignStyle." style='background-color:#efefef';>Tags: ". $links ."</div>";


_________________
Ole Bang Ottosen
Kommerciel Support, Migrering og Kurser i joomla 2.5 www.ot2sen.dk
Dansk Joomla! support websted - www.joomla.dk


Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 7:56 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Jul 18, 2008 2:28 pm
Posts: 786
Location: Dinajpur, Bangladesh
I tried this before. Tried again. It shows JText::_( 'Tags'), instead of "Tags" or tranlation.

_________________
http://Dinajpur.NET - My home district portal < not a Bangla joomla demo site ;)
http://RangpurBD.com - Rangpur Portal


Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 8:25 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 16630
Location: **Translation Matters**
As plugins language files are to be put in administrator/languages and it is a front-end plugin you may need to load the ini file in the .php

$lang =& JFactory::getLanguage();
$lang->load('plg_content_searchtag', JPATH_ADMINISTRATOR);

code could be something like
$article->text.="<br><br><div ".$alignStyle." style='background-color:#efefef';>".JText::_( 'Tags') .''. $links ."</div>";

_________________
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 9:09 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Jul 18, 2008 2:28 pm
Posts: 786
Location: Dinajpur, Bangladesh
infograf768 wrote:
$lang =& JFactory::getLanguage();
$lang->load('plg_content_searchtag', JPATH_ADMINISTRATOR);


Where to put this lines?
Should.. at the top in the php file?

_________________
http://Dinajpur.NET - My home district portal < not a Bangla joomla demo site ;)
http://RangpurBD.com - Rangpur Portal


Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 9:46 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Fri Aug 12, 2005 3:47 pm
Posts: 16630
Location: **Translation Matters**
almamun wrote:
infograf768 wrote:
$lang =& JFactory::getLanguage();
$lang->load('plg_content_searchtag', JPATH_ADMINISTRATOR);


Where to put this lines?
Should.. at the top in the php file?

After

parent::__construct( $subject, $params );

_________________
Jean-Marie Simonet / infograf · http://www.info-graf.fr
Multilanguage in 2.5: http://help.joomla.org/files/EN-GB_multilang_tutorial.pdf
---------------------------------
Joomla Translation Coordination Team • Joomla! Production Working Group


Top
 Profile  
 
PostPosted: Wed Sep 23, 2009 10:04 am 
User avatar
Joomla! Guru
Joomla! Guru

Joined: Fri Jul 18, 2008 2:28 pm
Posts: 786
Location: Dinajpur, Bangladesh
It works! :)

Thank you very much infograf768 & ot2sen

_________________
http://Dinajpur.NET - My home district portal < not a Bangla joomla demo site ;)
http://RangpurBD.com - Rangpur Portal


Top
 Profile  
 
PostPosted: Tue Dec 27, 2011 4:47 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Nov 16, 2009 1:19 am
Posts: 14
Location: Ελλάδα
I just put the lines

After

parent::__construct( $subject, $params );


As you said and it rolls! Thank you very much! Been searching for it for a long time! :)

_________________
http://levites.gr/


Top
 Profile  
 
PostPosted: Fri May 11, 2012 4:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Apr 16, 2012 4:12 pm
Posts: 9
ot2sen wrote:
Hi almamun,

Looks like the developer of this plugin didnt provide support of translating their extension, as there are no language ini-files included and there are hardcoded strings in the code.

So you would have to change the 'Tags' string directly in the code, or change in in the code in a way to allow the string to be translated by replacing the 'Tags' string with a JText::_( 'Tags') victorious episodes and a corresponding en-GB.plg_content_SearchTag.ini + a bn-BD.plg_content_SearchTag.ini both holding the translateable string: (en-GB) Tags=Tags and (bn-BD) Tags=your translation here

How you want to fix it depends whether you need just one or more languages at your site. If its just a one language site, you could go for the easy fix of just translating the two hardcoded strings in the code, marked in bold below:
Quote:
if ($links!=""){
$cssStyle=$this->param('cssStyle');
if($cssStyle){
$article->text.="<br><br><div class='".$cssStyle."'>Tags: ". $links ."</div>";
}else{
$align=$this->param('align');
$alignStyle="";
if($align!='none'){
$alignStyle=" align='".$align."'";
}
$article->text.="<br><br><div ".$alignStyle." style='background-color:#efefef';>Tags: ". $links ."</div>";



THIS IS PERFECT! I have been looking for something to do the same function as the 'SEO Search Terms Tag 2' plugin for wordpress. I am almost ready to launch mysite with the new Joomla platform and it is looking 10 times better then what I had with wordpress. Thanks for all the active support on these forums


edit: sorry admins for bumping such an old thread! :-[


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 



Who is online

Users browsing this forum: Google Feedfetcher and 191 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group