[ticket/9867] Adjust the implementation of error messages localization.

Use array_map instead of preg_replace.

PHPBB3-9867
This commit is contained in:
rxu 2010-10-26 01:38:09 +08:00
parent ecd648c996
commit 67b243cfc5
4 changed files with 12 additions and 12 deletions

View file

@ -921,7 +921,7 @@ class acp_users
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
if ($user_id == $user->data['user_id']) if ($user_id == $user->data['user_id'])
@ -1405,7 +1405,7 @@ class acp_users
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>'; $s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
@ -1588,7 +1588,7 @@ class acp_users
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$dateformat_options = ''; $dateformat_options = '';
@ -1714,7 +1714,7 @@ class acp_users
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
if (!$config['allow_avatar'] && $user_row['user_avatar_type']) if (!$config['allow_avatar'] && $user_row['user_avatar_type'])
@ -1857,7 +1857,7 @@ class acp_users
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$signature_preview = ''; $signature_preview = '';

View file

@ -105,7 +105,7 @@ class ucp_prefs
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$dateformat_options = ''; $dateformat_options = '';
@ -227,7 +227,7 @@ class ucp_prefs
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']); $sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);

View file

@ -239,7 +239,7 @@ class ucp_profile
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$template->assign_vars(array( $template->assign_vars(array(
@ -386,7 +386,7 @@ class ucp_profile
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
if ($config['allow_birthdays']) if ($config['allow_birthdays'])
@ -511,7 +511,7 @@ class ucp_profile
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
$signature_preview = ''; $signature_preview = '';
@ -582,7 +582,7 @@ class ucp_profile
$error[] = 'FORM_INVALID'; $error[] = 'FORM_INVALID';
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
} }
if (!$config['allow_avatar'] && $user->data['user_avatar_type']) if (!$config['allow_avatar'] && $user->data['user_avatar_type'])

View file

@ -220,7 +220,7 @@ class ucp_register
} }
// Replace "error" strings with their real, localised form // Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error); $error = array_map(array($user, 'lang'), $error);
if ($config['enable_confirm']) if ($config['enable_confirm'])
{ {