Recent Topics

1 Aug 07, 2015 16:32    

Hello guys,

I'm trying to add fr_FR locale to a plugin I've made, showing informations about the authors of posts, and it doesn't work, I can't understand why...
I've tried to make the files handly, using gettext/xg.php (it was not easy with Windows), uninstalled/reinstalled the plugin, the charset is correct, the _global.php file is UT-8 encoded... Am I missing something ?

There're only 3 lines :

<?php
	$trans[ 'fr_FR' ] = array(
		'' => 'Content-Type: text/plain; charset=utf-8',
		'About Author Plugin' => 'Plugin Author About',
		'When the option is checked, it adds a [About the Author] section at the end of the post, which displays the avatar and the [About me] field of the Author of the post.' => 'Quand il est coché, il ajoute une section -A propos de l\'Auteur- à la fin de chaque post, ce qui affiche le contenu du champ -About Me- du profil de l\'Auteur du post.',
		'About' => 'A propos de',	   
	);
?>

I'm using b2evo 5.1.2-stable

Example ("About" should appear as "A propos de") :
http://test.segakore.fr/index.php/2012/11/13/dreamcast-qui-reboot-l-autre-raison

Thanks for help.

2 Aug 07, 2015 22:46

Are you willing to share your plugin as open source, for example on github.com (free). This way it's much easier for us to look at it and see what might be wrong.

3 Aug 08, 2015 02:22

Hello,

because it totalises only 125 lines, I can copy it directly here :


<?php
/**
 * This file implements the About Author plugin.
 *
 * For the most recent and complete Plugin API documentation
 * see {@link Plugin} in ../evocore/_plugin.class.php.
 *
 * @package plugins
 *
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
 * @author igrekkess : iGREKKESS - {@link http://igrekkess.free.fr/}
 *
 * @version $Id: _about_me.plugin.php,v 1.1 2015/08/07 00:20:00 igrekkess Exp $
 */

if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );

/**
 * Blogalaxia_Tags Plugin
 *
 * This plugin responds to virtually all possible plugin events :P
 *
 * @package plugins
 */
class about_author_plugin extends Plugin
{
	/**
	 * Variables below MUST be overriden by plugin implementations,
	 * either in the subclass declaration or in the subclass constructor.
	 */
	var $name = 'About the Author';
	var $code = 'b2AboutAuthor';
	var $priority = 99;
	var $version = '1.1';
	var $group = 'rendering';
	var $author = 'iGREKKESS';
	var $help_url = '';  // empty URL defaults to manual wiki
	var $number_of_installs = 1;
	
	/**
	 * Init
	 *
	 * This gets called after a plugin has been registered/instantiated.
	 */
	function PluginInit( & $params )
	{
		$this->short_desc = T_('About Author Plugin');
		$this->long_desc = T_('When the option is checked, it adds a [About the Author] section at the end of the post, which displays the avatar and the [About me] field of the Author of the post.');
	}

	/* Define HTML Hook */
	function RenderItemAsHtml( & $params )
	{
		$this->insert_about_author_block( $params );
		return true;
	}

	/* Define XML Hook. Do nothing */
	function RenderItemAsXml ( & $params )
	{
		return true;
	}

	function insert_about_author_block( & $params )
	{
		global $disp ;
		$content = & $params['data'];
		$Item = & $params['Item'];

		// Params
		if( $disp == 'single' )
		{
			$params = array_merge( array(
				'profile_avatar_before'            => '',
				'profile_avatar_after'             => '',
				'avatar_image_size'                => 'fit-160x160',
			), $params );
			$UserCache = & get_UserCache();

			$author_id = $Item->creator_user_ID;
			$Author = & $UserCache->get_by_ID( $author_id );

			// Load the user fields:
			$Author->userfields_load();
			foreach( $Author->userfields as $userfield )
			{
				if($userfield->ufdf_name == 'About me' && !empty($userfield->uf_varchar)) {
					$about = nl2br($userfield->uf_varchar) ;
				}
			}
			if(isset($about) && !empty($about))
			{
				$avatar_overlay_text = '';
				$avatar_image_size = $params['avatar_image_size'];
				$avatar_imgtag = $params['profile_avatar_before'].$Author->get_avatar_imgtag( $avatar_image_size, '', '', true, $avatar_overlay_text, 'user' ).$params['profile_avatar_after'];
				$author_nickname = $Author->get( 'nickname' ) ;
				$content .= '
<!-- About the Author BEGIN -->
<div class="bComment form-horizontal">
<table style="width: 100%;" border="0" cellspacing="0" cellpadding="10">
<tbody>
<tr>
<td colspan="2"><legend>'.T_('About').' '.$author_nickname.'</legend></td>
</tr>
<tr>
<td>'.$avatar_imgtag.'</td>
<td style="text-align: justify; width: 100%;" valign="top">'.$about.'</td>
</tr>
</tbody>
</table>
</div>
<!-- About the Author END -->
				' ;
				$content .= "\n";
				return true;
			}
			else
			{
				return false;
			}
		}
	}
}

?>

4 Aug 08, 2015 02:58

Ok we'll check it out next week but please start by trying it on the latest version of b2evolution (6.6.2).

V5.1 is very old and about a million bugs have been fixed in between.

5 Aug 08, 2015 12:53

Ok thank you, I'll try.

6 Aug 12, 2015 13:48

Hello igrekkess,

I hope you put the code from your first message in a file /plugins/about_author_plugin/locales/fr_FR/_global.php as this is described on the manual page http://b2evolution.net/man/localizing-plugins

If yes, then you should do a small changing in your plugin code to use $this->T_( '...' ) instead of T_( '...' ), because this is a requirement of the same manual page:

  • The Plugin has to use the Plugin::T_() method, e.g. $this->T_('Hello world!'); (and not the global function with the same name).

I have tested those strings in fr_FR locale with your plugin and it works well on my side.

Thanks.

7 Aug 13, 2015 19:12

Thanks for your help, I've just added $this->, and now it's working fine ; I was definitely missing something !


Form is loading...