Adding missing smarty plugin translate implementation

This commit is contained in:
Erik Amaru Ortiz
2013-05-15 15:40:07 -04:00
parent d6af8e0fd1
commit fe700356b2
2 changed files with 29 additions and 1 deletions

View File

@@ -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);
}

View File

@@ -177,7 +177,7 @@
<body onload="resize()" onresize="resize()" > <body onload="resize()" onresize="resize()" >
<center> <center>
<div class="content-header" style="text-align:left"> <div class="content-header" style="text-align:left">
<h1 style="padding: 10px">{$title} ({$cases_count})</h1> <h1 style="padding: 10px">{$title} ({$cases_count}) {translate label="ID_USER"}</h1>
<ul id="commentlist"> <ul id="commentlist">
{include file='home/applications.html'} {include file='home/applications.html'}
</ul> </ul>