Skip to content

Commit 67b243c

Browse files
committed
[ticket/9867] Adjust the implementation of error messages localization.
Use array_map instead of preg_replace. PHPBB3-9867
1 parent ecd648c commit 67b243c

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

phpBB/includes/acp/acp_users.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,7 @@ function main($id, $mode)
921921
}
922922

923923
// Replace "error" strings with their real, localised form
924-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
924+
$error = array_map(array($user, 'lang'), $error);
925925
}
926926

927927
if ($user_id == $user->data['user_id'])
@@ -1405,7 +1405,7 @@ function main($id, $mode)
14051405
}
14061406

14071407
// Replace "error" strings with their real, localised form
1408-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1408+
$error = array_map(array($user, 'lang'), $error);
14091409
}
14101410

14111411
$s_birthday_day_options = '<option value="0"' . ((!$data['bday_day']) ? ' selected="selected"' : '') . '>--</option>';
@@ -1588,7 +1588,7 @@ function main($id, $mode)
15881588
}
15891589

15901590
// Replace "error" strings with their real, localised form
1591-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1591+
$error = array_map(array($user, 'lang'), $error);
15921592
}
15931593

15941594
$dateformat_options = '';
@@ -1714,7 +1714,7 @@ function main($id, $mode)
17141714
}
17151715

17161716
// Replace "error" strings with their real, localised form
1717-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1717+
$error = array_map(array($user, 'lang'), $error);
17181718
}
17191719

17201720
if (!$config['allow_avatar'] && $user_row['user_avatar_type'])
@@ -1857,7 +1857,7 @@ function main($id, $mode)
18571857
}
18581858

18591859
// Replace "error" strings with their real, localised form
1860-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
1860+
$error = array_map(array($user, 'lang'), $error);
18611861
}
18621862

18631863
$signature_preview = '';

phpBB/includes/ucp/ucp_prefs.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function main($id, $mode)
105105
}
106106

107107
// Replace "error" strings with their real, localised form
108-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
108+
$error = array_map(array($user, 'lang'), $error);
109109
}
110110

111111
$dateformat_options = '';
@@ -227,7 +227,7 @@ function main($id, $mode)
227227
}
228228

229229
// Replace "error" strings with their real, localised form
230-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
230+
$error = array_map(array($user, 'lang'), $error);
231231
}
232232

233233
$sort_dir_text = array('a' => $user->lang['ASCENDING'], 'd' => $user->lang['DESCENDING']);

phpBB/includes/ucp/ucp_profile.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ function main($id, $mode)
239239
}
240240

241241
// Replace "error" strings with their real, localised form
242-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
242+
$error = array_map(array($user, 'lang'), $error);
243243
}
244244

245245
$template->assign_vars(array(
@@ -386,7 +386,7 @@ function main($id, $mode)
386386
}
387387

388388
// Replace "error" strings with their real, localised form
389-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
389+
$error = array_map(array($user, 'lang'), $error);
390390
}
391391

392392
if ($config['allow_birthdays'])
@@ -511,7 +511,7 @@ function main($id, $mode)
511511
}
512512

513513
// Replace "error" strings with their real, localised form
514-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
514+
$error = array_map(array($user, 'lang'), $error);
515515
}
516516

517517
$signature_preview = '';
@@ -582,7 +582,7 @@ function main($id, $mode)
582582
$error[] = 'FORM_INVALID';
583583
}
584584
// Replace "error" strings with their real, localised form
585-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
585+
$error = array_map(array($user, 'lang'), $error);
586586
}
587587

588588
if (!$config['allow_avatar'] && $user->data['user_avatar_type'])

phpBB/includes/ucp/ucp_register.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ function main($id, $mode)
220220
}
221221

222222
// Replace "error" strings with their real, localised form
223-
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$user->lang['\\1'])) ? \$user->lang['\\1'] : '\\1'", $error);
223+
$error = array_map(array($user, 'lang'), $error);
224224

225225
if ($config['enable_confirm'])
226226
{

0 commit comments

Comments
 (0)