SearchTag plugin.. translating "Tags"

A place to discuss Joomla! translation matters.

Moderator: wendhausen

Locked
User avatar
almamun
Joomla! Guru
Joomla! Guru
Posts: 798
Joined: Fri Jul 18, 2008 2:28 pm
Location: Dinajpur, Bangladesh
Contact:

SearchTag plugin.. translating "Tags"

Post by almamun » Tue Sep 22, 2009 5:48 pm

I need the word "Tags" in SearchTag plugin translated. No language file, No support by the developer.

Pls help.

Code: Select all

<?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);
 }
	
}
?>
Last edited by almamun on Wed Sep 23, 2009 10:05 am, edited 1 time in total.
Bengali (Bangladesh) Forum Moderator

http://amviro.com - Web & App Development.

User avatar
ot2sen
Joomla! Master
Joomla! Master
Posts: 10381
Joined: Thu Aug 18, 2005 9:58 am
Location: Hillerød - Denmark
Contact:

Re: SearchTag plugin.. translating "Tags"

Post by ot2sen » Wed Sep 23, 2009 7:37 am

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:
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
Dansk frivillig Joomla! support websted - joomla.dk
OpenTranslators Core Team opentranslators.org

User avatar
almamun
Joomla! Guru
Joomla! Guru
Posts: 798
Joined: Fri Jul 18, 2008 2:28 pm
Location: Dinajpur, Bangladesh
Contact:

Re: SearchTag plugin.. translating "Tags"

Post by almamun » Wed Sep 23, 2009 7:56 am

I tried this before. Tried again. It shows JText::_( 'Tags'), instead of "Tags" or tranlation.
Bengali (Bangladesh) Forum Moderator

http://amviro.com - Web & App Development.

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SearchTag plugin.. translating "Tags"

Post by infograf768 » Wed Sep 23, 2009 8:25 am

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
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
almamun
Joomla! Guru
Joomla! Guru
Posts: 798
Joined: Fri Jul 18, 2008 2:28 pm
Location: Dinajpur, Bangladesh
Contact:

Re: SearchTag plugin.. translating "Tags"

Post by almamun » Wed Sep 23, 2009 9:09 am

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?
Bengali (Bangladesh) Forum Moderator

http://amviro.com - Web & App Development.

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SearchTag plugin.. translating "Tags"

Post by infograf768 » Wed Sep 23, 2009 9:46 am

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
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
almamun
Joomla! Guru
Joomla! Guru
Posts: 798
Joined: Fri Jul 18, 2008 2:28 pm
Location: Dinajpur, Bangladesh
Contact:

Re: SearchTag plugin.. translating "Tags"

Post by almamun » Wed Sep 23, 2009 10:04 am

It works! :)

Thank you very much infograf768 & ot2sen
Bengali (Bangladesh) Forum Moderator

http://amviro.com - Web & App Development.

Fonias
Joomla! Apprentice
Joomla! Apprentice
Posts: 14
Joined: Mon Nov 16, 2009 1:19 am
Location: Ελλάδα
Contact:

Re: SearchTag plugin.. translating "Tags"

Post by Fonias » Tue Dec 27, 2011 4:47 am

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! :)

Roundhouse
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Mon Apr 16, 2012 4:12 pm

Re: SearchTag plugin.. translating "Tags"

Post by Roundhouse » Fri May 11, 2012 4:04 pm

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:
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! :-[

petrosal
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Sat May 11, 2013 12:46 pm

Re: SearchTag plugin.. translating "Tags"

Post by petrosal » Tue Jun 11, 2013 8:47 am

I create a new plugin for joomla 2.5, and in xml i use:

Code: Select all

<description>PLG_VAR_DESC</description> 
But when install, he dont show the the translation but the var on file.

Code: Select all

<languages folder="">
  <language tag="en-GB">en-GB.plg_system_name.ini</language>
  <language tag="en-GB">en-GB.plg_system_name.sys.ini</language>
</languages>
<files>
   <folder>images</folder>
   <filename>index.html</filename>
   <filename>parameters.xml</filename>
   <filename plugin="plg_name">plg_name.php</filename>
</files>
I try everything but i cant put this work..

Thanks

farshidp
I've been banned!
Posts: 9
Joined: Wed Jul 10, 2013 6:16 am

Re: SearchTag plugin.. translating "Tags"

Post by farshidp » Tue Jul 16, 2013 2:31 pm

hi infograf768
i cant find
parent::__construct( $subject, $params );
where is it?

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SearchTag plugin.. translating "Tags"

Post by infograf768 » Wed Jul 17, 2013 5:37 am

petrosal wrote:I create a new plugin for joomla 2.5, and in xml i use:

Code: Select all

<description>PLG_VAR_DESC</description> 
But when install, he dont show the the translation but the var on file.

Code: Select all

<languages folder="">
  <language tag="en-GB">en-GB.plg_system_name.ini</language>
  <language tag="en-GB">en-GB.plg_system_name.sys.ini</language>
</languages>
<files>
   <folder>images</folder>
   <filename>index.html</filename>
   <filename>parameters.xml</filename>
   <filename plugin="plg_name">plg_name.php</filename>
</files>
I try everything but i cant put this work..

Thanks
Look how it is made in the core languagecode plugin.
You have to create a language folder and put your ini files in it
language/en-GB/ your ini files
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
infograf768
Joomla! Master
Joomla! Master
Posts: 19133
Joined: Fri Aug 12, 2005 3:47 pm
Location: **Translation Matters**

Re: SearchTag plugin.. translating "Tags"

Post by infograf768 » Wed Jul 17, 2013 5:38 am

farshidp wrote:hi infograf768
i cant find
parent::__construct( $subject, $params );
where is it?
Please look at the core plugins code.
Jean-Marie Simonet / infograf
---------------------------------
ex-Joomla Translation Coordination Team • ex-Joomla! Production Working Group

User avatar
pishro
Joomla! Explorer
Joomla! Explorer
Posts: 301
Joined: Tue Oct 09, 2012 7:22 am

Re: SearchTag plugin.. translating "Tags"

Post by pishro » Thu Dec 19, 2013 6:03 pm


terdono
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Wed Aug 14, 2013 6:38 am

Re: SearchTag plugin.. translating "Tags"

Post by terdono » Fri Jul 25, 2014 10:46 am

Smart Reach for fieldsattach is a native Joomla! 2.5.x plugin for Joomla Finder/Smart Search.


Locked

Return to “Translations”