Adding missing smarty plugin translate implementation
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* To implement pmos translation function on smarty templates
|
||||
*
|
||||
* example use:
|
||||
*
|
||||
* <h1>{translate label="ID_HOME_TITLE"}</h1>
|
||||
*
|
||||
* @params $params mixed array containg all parameters passed from smarty plugin call
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
|
||||
function translate($params)
|
||||
{
|
||||
if (array_key_exists('lang', $params)) {
|
||||
$lang = $params['lang'];
|
||||
} elseif (defined('SYS_LANG')) {
|
||||
$lang = SYS_LANG;
|
||||
} else {
|
||||
$lang = 'en';
|
||||
}
|
||||
|
||||
if (! array_key_exists('label', $params)) {
|
||||
throw new Exception('Error: Param "label" is missing on "tranlate" smarty function, it should be called like: {translate label="SOME_LABEL_ID"}');
|
||||
}
|
||||
|
||||
echo G::loadTranslation($params['label'], $lang);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user