[dokuwiki] Re: language files in action plugins

  • From: "Martin Tschofen" <martin.tschofen@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Sat, 3 Feb 2007 21:46:15 -0600

I'm stuck with this problem. I'm sure I'm missing something simple. I
stripped the action plugin down. The "test" message is all that comes back.
I do have a file in lang/en/lang.php with
   $lang['page_header'] = 'Select and organize pages';

as well as a file lang/en/intro.txt with some wiki text.

Neither of these language specific information shows up. I'm not sure what
else to try.

Thanks...martin

<?php
if(!defined('DOKU_INC'))
define('DOKU_INC',realpath(dirname(__FILE__).'/../../../').'/');
 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
 require_once(DOKU_PLUGIN.'action.php');

class action_plugin_full_index extends DokuWiki_Action_Plugin {

function action_plugin_full_index(){
$this->setupLocale();
}

 function register(&$controller) {
   $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this,
'html_index_clickable');
 }

 function html_index_clickable(&$event){
print $this->plugin_locale_xhtml('intro');
print $this->getLang('page_header');
print "test";
$event->preventDefault();
$event->stopPropagation();
 }

} //end of action class


On 1/25/07, Martin Tschofen <martin.tschofen@xxxxxxxxx> wrote:

I'm running develonly. But just to check it out, I threw it into the
latest release with the same result.

Any idea how I can track this down?...martin

On 1/25/07, Chris Smith <chris@xxxxxxxxxxxxx> wrote:
>
> Martin Tschofen wrote:
> > I'm stuck with using language files in an action plugin.
> > The action plugin replaces the current index. I cannot figure out how
> > I can
> > access the language settings when using
> > $this->getLang('name=of=the=property'); It always returns empty, no
> > error.
> >
> > I'm even setting the locale in the constructor, even though getLang
> > should
> > do that anyway:
> > $this->setupLocale();
> >
> > Here's how I retrieve the page_header within a function:
> > print $this->getLang('page_header');
> >
> > page_header is in the lang/en/lang.php file as
> >               $lang['page_header'] = 'Select and organize pages';
> >
> > The same issue happens with
> > print p_locale_xhtml('index');
> > It always returns the index from the DW global language directory.
> >
> > $this->lang only returns a blank array.
> >
> > The same approach works just fine in an admin plugin.
> >
> > Any idea what's different with action plugins and language settings?
> >
> > Thanks...martin
> >
> There shouldn't be any difference, both inherit from the same base class
> which provides the introspection, config and localisation methods.  Are
> you running develonly?  Andi moved the base class from /lib/plugins into
>
> /inc in a recent patch.  Maybe something became broken.
>
>
> Cheers,
>
> Chris
> --
> DokuWiki mailing list - more info at
> http://wiki.splitbrain.org/wiki:mailinglist
>


Other related posts: