| 15 |
switch ($form_id) { |
switch ($form_id) { |
| 16 |
case 'user_register': |
case 'user_register': |
| 17 |
case 'user_edit': |
case 'user_edit': |
| 18 |
// Match the text inside label tags. |
_civicrm_localize_alter($form); |
|
$regex = '|(<label.*?>)(.*?)(<\/.*?>)|'; |
|
|
foreach (element_children($form) as $key) { |
|
|
// CiviCRM elements have no '#type' set. Assume if there is no '#type' that this |
|
|
// is a field we need to alter. |
|
|
if (isset($form[$key]['#value']) && !isset($form[$key]['#type'])) { |
|
|
$form[$key]['#value'] = preg_replace_callback($regex, '_civicrm_localize_replace', $form[$key]['#value']); |
|
|
} |
|
|
} |
|
| 19 |
break; |
break; |
| 20 |
} |
} |
| 21 |
} |
} |
| 22 |
|
|
| 23 |
/** |
/** |
| 24 |
|
* Helper function for iterating and processing forms. |
| 25 |
|
*/ |
| 26 |
|
function _civicrm_localize_alter(&$element) { |
| 27 |
|
// Match the text inside label tags. |
| 28 |
|
$regex = '|(<label.*?>)(.*?)(<\/.*?>)|'; |
| 29 |
|
foreach (element_children($element) as $key) { |
| 30 |
|
// CiviCRM elements have no '#type' set. Assume if there is no '#type' that this |
| 31 |
|
// is a field we need to alter. |
| 32 |
|
if (isset($element[$key]['#value']) && !isset($element[$key]['#type'])) { |
| 33 |
|
$element[$key]['#value'] = preg_replace_callback($regex, '_civicrm_localize_replace', $element[$key]['#value']); |
| 34 |
|
} |
| 35 |
|
} |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
/** |
| 39 |
* Helper function for localization. |
* Helper function for localization. |
| 40 |
*/ |
*/ |
| 41 |
function _civicrm_localize_replace($matches) { |
function _civicrm_localize_replace($matches) { |