Line | |
---|
1 | <?php |
---|
2 | /** |
---|
3 | * Smarty plugin |
---|
4 | * @package Smarty |
---|
5 | * @subpackage plugins |
---|
6 | */ |
---|
7 | |
---|
8 | |
---|
9 | /** |
---|
10 | * Smarty {t} plugin |
---|
11 | * |
---|
12 | * Type: function<br> |
---|
13 | * Name: t<br> |
---|
14 | * Purpose: replace message alias to appropriate strings |
---|
15 | * @author pineray 松田光貴 <matsudaterutaka at gmail dot com> |
---|
16 | * @param array |
---|
17 | * @param Smarty |
---|
18 | * @return string |
---|
19 | */ |
---|
20 | function smarty_function_t($params, &$smarty) { |
---|
21 | // エイリアスが無ければエラーを出力 |
---|
22 | if (empty($params['string'])) { |
---|
23 | $smarty->_trigger_fatal_error("[plugin] parameter 'string' cannot be empty"); |
---|
24 | return; |
---|
25 | } |
---|
26 | $string = $params['string']; |
---|
27 | unset($params['string']); |
---|
28 | |
---|
29 | // オプション用の配列 |
---|
30 | $options = array(); |
---|
31 | // 言語コードの指定があればオプションにセット |
---|
32 | if (!empty($params['lang_code'])) { |
---|
33 | $options['lang_code'] = $params['lang_code']; |
---|
34 | unset($params['lang_code']); |
---|
35 | } |
---|
36 | // 機種の指定があればオプションにセット |
---|
37 | if (!empty($params['device_type_id'])) { |
---|
38 | $options['device_type_id'] = $params['device_type_id']; |
---|
39 | unset($params['device_type_id']); |
---|
40 | } |
---|
41 | |
---|
42 | return SC_Utils_Ex::t($string, $params, $options); |
---|
43 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.