3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Smarty block function for multilingualizing upgrade SQL queries.
20 * The string passed in $text is repeated locale-number times, with the
21 * param field (if provided) appended with a different locale every time.
23 * @param array $params
24 * Template call's parameters.
26 * {ts} block contents from the template.
27 * @param CRM_Core_Smarty $smarty
31 * multilingualized query
33 function smarty_block_localize($params, $text, &$smarty) {
34 if (!array_key_exists('multilingual', $smarty->_tpl_vars
) ||
!$smarty->_tpl_vars
['multilingual']) {
39 foreach ($smarty->_tpl_vars
['locales'] as $locale) {
41 if (isset($params['field'])) {
42 $fields = explode(',', $params['field']);
43 foreach ($fields as $field) {
44 $field = trim($field);
45 $line = preg_replace('/\b' . preg_quote($field) . '\b/', "{$field}_{$locale}", $line);
51 return implode(', ', $lines);