wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
function.translate.php
Go to the documentation of this file.
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2014 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of any of the following licenses
7  * at your choice:
8  *
9  * - GNU Lesser General Public License (LGPL)
10  * http://www.gnu.org/licenses/lgpl.html
11  * - Eclipse Public License (EPL)
12  * http://www.eclipse.org/org/documents/epl-v10.php
13  *
14  * See the license.txt file distributed with this work for
15  * additional information.
16  *
17  * $Id: function.translate.php 1462 2014-02-04 23:52:27Z iherwig $
18  */
19 
20 /*
21 * Smarty plugin
22 * -------------------------------------------------------------
23 * File: function.translate.php
24 * Type: function
25 * Name: translate
26 * Purpose: translate a text
27 * Usage: e.g. {translate text="Logged in as %1% since %2%" r0="$login" r1="$logindate" [varname="loginText"]}
28 * -------------------------------------------------------------
29 */
30 function smarty_function_translate($params, &$smarty)
31 {
32  $variables = array();
33  foreach (array_keys($params) as $key)
34  if (preg_match("/^r[0-9]+$/", $key))
35  array_push($variables, $params[$key]);
36 
37  $value = Message::get($params['text'], $variables, $params['domain'], $params['lang']);
38  if (isset($params['varname']))
39  $smarty->assign($params['varname'], $value);
40  else
41  echo $value;
42 }
43 ?>
get($message, $parameters=null, $domain='', $lang='')
smarty_function_translate($params, &$smarty)