[TYPO3-dev] getting at locallang_db.php in an FE plugin

Bernd Wilke xoonsji02 at sneakemail.com
Mon Apr 10 11:48:41 CEST 2006


On Mon, 10 Apr 2006 15:02:51 +0700, Markus bertheau wrote
with subject "[TYPO3-dev] getting at locallang_db.php in an FE plugin":

> Hi,
> 
> how would I get at the values in the $LOCAL_LANG array from
> locallang_db.php in a frontend plugin? It seems locallang_db.php does
> not get loaded for the frontend; so pi_getLL() returns an empty
> string.

a little bit complex on the first sight:

insert/update/verify the following lines in your extension-class:
(positions as given in your file, numbers as your work-flow)


1. require_once(t3lib_extMgm::extPath('lang').'lang.php')

class tx_... extends tslib_pibase {

2. var $LL		//array with locallang-values
   var $LANG		// object to access $LL 
			// 'global $LANG' should be enough, but failed 

function main($content,$conf) {

3. $this->LL = $this->includeLocalLang();	// load external locallang
   $this->LANG = t3lib_dev::makeInstance('language');	// create
						// language-object
   $LLkey='default';
   if ($GLOBALS['TSFE']->config['config']['language'])	{
	$LLkey = $GLOBALS['TSFE']->config['config']['language'];
   }
   $this->LANG->init($LLkey)	// initalize language-object 
				// with actual language


6.	$text = $this->my_getLL('key');

}

4. function includeLocalLang() {
					// get path to desired locallang
	include(t3lib_dev::extPath($extkey).'locallang_DB.php');   
	return $LOCAL_LANG;
   }

5. function my_getLL($k,$alt='',$hsc=true) {
	$retval=$this->pi_getLL($k,'',$hsc);
	if (!$retval) $retval = $this->LANG->getLLL($k,$this->LL,$hsc);
	if (!$retval) $retval=$alt;
	return $retval;
   }
}


good luck
Bernd

-- 
----------------
Bernd Wilke     
Annweilerstr.20 
40229 Düsseldorf
0211/229 2800




More information about the TYPO3-dev mailing list