load language variables

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Meis2M
Translator
Posts: 1009
Joined: Wed Mar 03, 2010 11:32 am
Location: IR.Damghan
Name: میثم نوبری
Contact:

load language variables

Post by Meis2M »

Hello

is main_listener.php duty load language?

i have a problem with load language variables my event/main_listener.php is

Code: Select all

<?php
/**
*
* @package phpBB Extension - AJAX Advanced Forum Stats
* @copyright (c) 2018 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace meis2m\aafs\event;
/**
* @ignore
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Event listener
*/
class main_listener implements EventSubscriberInterface
{
	static public function getSubscribedEvents()
	{
		return array(
			'core.user_setup'	=> 'load_language_on_setup',
		);
	}
	/* @var \phpbb\controller\helper */
	protected $helper;
	/* @var \phpbb\template\template */
	protected $template;
	/**
	* Constructor
	*
	* @param \phpbb\controller\helper	$helper		Controller helper object
	* @param \phpbb\template\template	$template	Template object
	*/
	public function __construct(\phpbb\controller\helper $helper, \phpbb\template\template $template)
	{
		$this->helper = $helper;
		$this->template = $template;
	}
	public function load_language_on_setup($event)
	{
		$lang_set_ext = $event['lang_set_ext'];
		$lang_set_ext[] = array(
			'ext_name' => 'meis2m/aafs',
			'lang_set' => 'common',
		);
		$event['lang_set_ext'] = $lang_set_ext;
	}

}
but in .htmls files the languages variables not working yet, what is missed?
phpBB persian international support
Follow us in Instagram
Free upgrade and install extensions on your forum - drop me PM
Ultimate phpBB SEO Friendly URL extension
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: load language variables

Post by Kailey »

Are you sure your language file has the language variables that the HTML file uses?
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
Meis2M
Translator
Posts: 1009
Joined: Wed Mar 03, 2010 11:32 am
Location: IR.Damghan
Name: میثم نوبری
Contact:

Re: load language variables

Post by Meis2M »

this is my service

Code: Select all

services:
    meis2m.aafs.controller:
        class: meis2m\aafs\controller\main
        arguments:
            - '@config'
            - '@controller.helper'
            - '@template'
            - '@user'
    meis2m.aafs.listener:
        class: meis2m\aafs\event\main_listener
        arguments:
            - '@controller.helper'
            - '@template'

and it is part of my html:

Code: Select all

<tr align="top"><th colspan="2" align="left">{L_TFORUM_STATS}</th></tr>
and language file:

Code: Select all

<?php

if (!defined('IN_PHPBB'))
{
	exit;
}

if (empty($lang) || !is_array($lang))
{
	$lang = array();
}

$lang = array_merge($lang, array(
	'TFORUM_STATS'	=> 'Forum Stats',
	'TNEWEST_MEM'	=> 'Newest Member',
	'TTOP_THANKED'	=> 'Top Thanked',
	'TTOP_POSTER'	=> 'Top Poster',
	'TNEW_THREAD'	=> 'Latest Post',
	'TMOST_VIEW'	=> 'Most Viewed',
	'THOT_TOPIC'	=> 'Hotest Thread',
	 'NEWEST_TOPICS'		=> 'Newest topic',
	'ACTIVE_MEM'	=> 'Top poster',
    'NEWEST_MEM'	=> 'Newest member',
	'BY'                => 'by',
	'VIEWS'		=> 'Views',
	'REPLY'		=> 'Reply',
	'THANKED'		=> 'Thanked',
	'TOPICS'		=> 'Topic',
	'REGDATE'		=> 'Date',
	'POSTER'		=> 'Author',
	'LATEST_POSTER'		=> 'Last reply',
	'LATEST_POST_TIME'	=> 'Last post time',
	'POST_TIME'		=> 'Post time',
	'TIMES'			=> 'times',
));

?>
it seems every thing is ok
phpBB persian international support
Follow us in Instagram
Free upgrade and install extensions on your forum - drop me PM
Ultimate phpBB SEO Friendly URL extension
User avatar
Kailey
Community Team Leader
Community Team Leader
Posts: 3732
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Snay
Contact:

Re: load language variables

Post by Kailey »

You're missing the tags part for your listener. See https://github.com/kinerity/trackers/bl ... ml#L26-L33

Also, if you are not using the helper and template objects, you can remove them.
Kailey Snay - Community Team Leader
Knowledge Base | Documentation | Community rules

If you have any questions about the rules/customs of this website, feel free to send me a PM.
User avatar
Meis2M
Translator
Posts: 1009
Joined: Wed Mar 03, 2010 11:32 am
Location: IR.Damghan
Name: میثم نوبری
Contact:

Re: load language variables

Post by Meis2M »

Thank you...

my service is now

Code: Select all

services:
    meis2m.aafs.controller:
        class: meis2m\aafs\controller\main
        arguments:
            - '@config'
            - '@controller.helper'
            - '@template'
            - '@user'
    meis2m.aafs.listener:
        class: meis2m\aafs\event\main_listener
        arguments:
            - '@service_container'
            - '@controller.helper'
            - '@template'
        tags:
- { name: event.listener }
    
but i have this error:



phpBB encountered an error building the container due to an installed extension. For this reason, all extensions have been temporarily disabled. Please try purging your forum cache. All extensions will automatically be re-enabled once the container error is resolved. If this error continues, please visit phpBB.com for support.

Code: Select all

Exception: The file "C:\xampp\htdocs\phpbb\phpBB3\ext\meis2m\aafs\config\services.yml" does not contain valid YAML.

#0 C:\xampp\htdocs\phpbb\phpBB3\vendor\symfony\dependency-injection\Loader\YamlFileLoader.php(44): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->loadFile('C:\\xampp\\htdocs...')
#1 C:\xampp\htdocs\phpbb\phpBB3\phpbb\extension\di\extension_base.php(99): Symfony\Component\DependencyInjection\Loader\YamlFileLoader->load('services.yml')
#2 C:\xampp\htdocs\phpbb\phpBB3\phpbb\extension\di\extension_base.php(63): phpbb\extension\di\extension_base->load_services(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#3 C:\xampp\htdocs\phpbb\phpBB3\vendor\symfony\dependency-injection\Compiler\MergeExtensionConfigurationPass.php(59): phpbb\extension\di\extension_base->load(Array, Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#4 C:\xampp\htdocs\phpbb\phpBB3\vendor\symfony\http-kernel\DependencyInjection\MergeExtensionConfigurationPass.php(39): Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#5 C:\xampp\htdocs\phpbb\phpBB3\vendor\symfony\dependency-injection\Compiler\Compiler.php(102): Symfony\Component\HttpKernel\DependencyInjection\MergeExtensionConfigurationPass->process(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#6 C:\xampp\htdocs\phpbb\phpBB3\vendor\symfony\dependency-injection\ContainerBuilder.php(583): Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Symfony\Component\DependencyInjection\ContainerBuilder))
#7 C:\xampp\htdocs\phpbb\phpBB3\phpbb\di\container_builder.php(191): Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#8 C:\xampp\htdocs\phpbb\phpBB3\common.php(115): phpbb\di\container_builder->get_container()
#9 C:\xampp\htdocs\phpbb\phpBB3\adm\index.php(23): require('C:\\xampp\\htdocs...')
#10 {main}
phpBB persian international support
Follow us in Instagram
Free upgrade and install extensions on your forum - drop me PM
Ultimate phpBB SEO Friendly URL extension
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: load language variables

Post by david63 »

The answer is in the first line
Exception: The file "C:\xampp\htdocs\phpbb\phpBB3\ext\meis2m\aafs\config\services.yml" does not contain valid YAML.

Google yml format checker and use it to check your services file.

You may have tab, or a space in the wrong place.

.yml files are very precise in their formatting, get one character wrong and it will not work.
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
Meis2M
Translator
Posts: 1009
Joined: Wed Mar 03, 2010 11:32 am
Location: IR.Damghan
Name: میثم نوبری
Contact:

Re: load language variables

Post by Meis2M »

Thank you... new error

what is that?

Code: Select all

Exception: The definition for "tags" has no class. If you intend to inject this service dynamically at runtime, please mark it as synthetic=true. If this is an abstract definition solely used by child definitions, please add abstract=true, otherwise specify a class to get rid of this error.
phpBB persian international support
Follow us in Instagram
Free upgrade and install extensions on your forum - drop me PM
Ultimate phpBB SEO Friendly URL extension
User avatar
Meis2M
Translator
Posts: 1009
Joined: Wed Mar 03, 2010 11:32 am
Location: IR.Damghan
Name: میثم نوبری
Contact:

Re: load language variables

Post by Meis2M »

i fixed it..
thank you... now languages is working perfectly
phpBB persian international support
Follow us in Instagram
Free upgrade and install extensions on your forum - drop me PM
Ultimate phpBB SEO Friendly URL extension
Post Reply

Return to “Extension Writers Discussion”