diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2011-09-14 00:28:52 +0200 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-11-25 15:10:44 -0500 |
commit | 88ae40a4b19360645d5e5a614cc378e7cce4afe3 (patch) | |
tree | 057ddd8d25a1ec8b943b8f95cab9c861a385285b /phpBB/includes | |
parent | 0734dd3c42f573d819c058cd6c6b55d035d1836d (diff) | |
download | forums-88ae40a4b19360645d5e5a614cc378e7cce4afe3.tar forums-88ae40a4b19360645d5e5a614cc378e7cce4afe3.tar.gz forums-88ae40a4b19360645d5e5a614cc378e7cce4afe3.tar.bz2 forums-88ae40a4b19360645d5e5a614cc378e7cce4afe3.tar.xz forums-88ae40a4b19360645d5e5a614cc378e7cce4afe3.zip |
[ticket/10345] Make use of the plural function in some basic places
PHPBB3-10345
Diffstat (limited to 'phpBB/includes')
-rw-r--r-- | phpBB/includes/acp/acp_icons.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions.php | 62 | ||||
-rw-r--r-- | phpBB/includes/functions_content.php | 16 | ||||
-rw-r--r-- | phpBB/includes/functions_display.php | 4 | ||||
-rw-r--r-- | phpBB/includes/functions_privmsgs.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_forum.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_front.php | 53 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_logs.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_notes.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_pm_reports.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_queue.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_reports.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_topic.php | 2 | ||||
-rw-r--r-- | phpBB/includes/mcp/mcp_warn.php | 2 | ||||
-rw-r--r-- | phpBB/includes/message_parser.php | 2 | ||||
-rw-r--r-- | phpBB/includes/session.php | 3 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_main.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_options.php | 4 | ||||
-rw-r--r-- | phpBB/includes/ucp/ucp_pm_viewfolder.php | 2 |
20 files changed, 54 insertions, 122 deletions
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index c848039c66..98aef45892 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -379,7 +379,7 @@ class acp_icons if ($smiley_count + $addable_smileys_count > SMILEY_LIMIT) { - trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); } } @@ -599,7 +599,7 @@ class acp_icons $smiley_count = $this->item_count($table); if ($smiley_count + sizeof($pak_ary) > SMILEY_LIMIT) { - trigger_error(sprintf($user->lang['TOO_MANY_SMILIES'], SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); + trigger_error($user->lang('TOO_MANY_SMILIES', SMILEY_LIMIT) . adm_back_link($this->u_action), E_USER_WARNING); } } diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 92273bf08c..a663286f5f 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -4120,59 +4120,26 @@ function obtain_users_online_string($online_users, $item_id = 0, $item = 'forum' } else if ($config['load_online_guests']) { - $l_online = ($online_users['guests_online'] === 1) ? $user->lang['BROWSING_' . $item_caps . '_GUEST'] : $user->lang['BROWSING_' . $item_caps . '_GUESTS']; - $online_userlist = sprintf($l_online, $online_userlist, $online_users['guests_online']); + $online_userlist = $user->lang('BROWSING_' . $item_caps . '_GUESTS', $online_users['guests_online'], $online_userlist); } else { $online_userlist = sprintf($user->lang['BROWSING_' . $item_caps], $online_userlist); } // Build online listing - $vars_online = array( - 'ONLINE' => array('total_online', 'l_t_user_s', 0), - 'REG' => array('visible_online', 'l_r_user_s', !$config['load_online_guests']), - 'HIDDEN' => array('hidden_online', 'l_h_user_s', $config['load_online_guests']), - 'GUEST' => array('guests_online', 'l_g_user_s', 0) - ); + $visible_online = $user->lang('REG_USERS_TOTAL', (int) $online_users['visible_online']); + $hidden_online = $user->lang('HIDDEN_USERS_TOTAL', (int) $online_users['hidden_online']); - foreach ($vars_online as $l_prefix => $var_ary) + if ($config['load_online_guests']) { - if ($var_ary[2]) - { - $l_suffix = '_AND'; - } - else - { - $l_suffix = ''; - } - switch ($online_users[$var_ary[0]]) - { - case 0: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_ZERO_TOTAL' . $l_suffix]; - break; - - case 1: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USER_TOTAL' . $l_suffix]; - break; - - default: - ${$var_ary[1]} = $user->lang[$l_prefix . '_USERS_TOTAL' . $l_suffix]; - break; - } + $guests_online = $user->lang('GUEST_USERS_TOTAL', (int) $online_users['guests_online']); + $l_online_users = $user->lang('ONLINE_USERS_TOTAL_GUESTS', (int) $online_users['total_online'], $visible_online, $hidden_online, $guests_online); } - unset($vars_online); - - $l_online_users = sprintf($l_t_user_s, $online_users['total_online']); - $l_online_users .= sprintf($l_r_user_s, $online_users['visible_online']); - $l_online_users .= sprintf($l_h_user_s, $online_users['hidden_online']); - - if ($config['load_online_guests']) + else { - $l_online_users .= sprintf($l_g_user_s, $online_users['guests_online']); + $l_online_users = $user->lang('ONLINE_USERS_TOTAL', (int) $online_users['total_online'], $visible_online, $hidden_online); } - - return array( 'online_userlist' => $online_userlist, 'l_online_users' => $l_online_users, @@ -4393,10 +4360,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 set_config('record_online_date', time(), true); } - $l_online_record = sprintf($user->lang['RECORD_ONLINE_USERS'], $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); + $l_online_record = $user->lang('RECORD_ONLINE_USERS', (int) $config['record_online_users'], $user->format_date($config['record_online_date'], false, true)); - $l_online_time = ($config['load_online_time'] == 1) ? 'VIEW_ONLINE_TIME' : 'VIEW_ONLINE_TIMES'; - $l_online_time = sprintf($user->lang[$l_online_time], $config['load_online_time']); + $l_online_time = $user->lang('VIEW_ONLINE_TIMES', (int) $config['load_online_time']); } $l_privmsgs_text = $l_privmsgs_text_unread = ''; @@ -4407,8 +4373,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 { if ($user->data['user_new_privmsg']) { - $l_message_new = ($user->data['user_new_privmsg'] == 1) ? $user->lang['NEW_PM'] : $user->lang['NEW_PMS']; - $l_privmsgs_text = sprintf($l_message_new, $user->data['user_new_privmsg']); + $l_privmsgs_text = $user->lang('NEW_PMS', (int) $user->data['user_new_privmsg']); if (!$user->data['user_last_privmsg'] || $user->data['user_last_privmsg'] > $user->data['session_last_visit']) { @@ -4426,7 +4391,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 } else { - $l_privmsgs_text = $user->lang['NO_NEW_PM']; + $l_privmsgs_text = $user->lang('NEW_PMS', 0); $s_privmsg_new = false; } @@ -4434,8 +4399,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 if ($user->data['user_unread_privmsg'] && $user->data['user_unread_privmsg'] != $user->data['user_new_privmsg']) { - $l_message_unread = ($user->data['user_unread_privmsg'] == 1) ? $user->lang['UNREAD_PM'] : $user->lang['UNREAD_PMS']; - $l_privmsgs_text_unread = sprintf($l_message_unread, $user->data['user_unread_privmsg']); + $l_privmsgs_text_unread = $user->lang('UNREAD_PMS', (int) $user->data['user_unread_privmsg']); } } diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index b1294a2f14..894e261c12 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -938,12 +938,12 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, } $download_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); + $l_downloaded_viewed = 'VIEWED_COUNTS'; switch ($display_cat) { // Images case ATTACHMENT_CATEGORY_IMAGE: - $l_downloaded_viewed = 'VIEWED_COUNT'; $inline_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id']); $download_link .= '&mode=view'; @@ -957,7 +957,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, // Images, but display Thumbnail case ATTACHMENT_CATEGORY_THUMB: - $l_downloaded_viewed = 'VIEWED_COUNT'; $thumbnail_link = append_sid("{$phpbb_root_path}download/file.$phpEx", 'id=' . $attachment['attach_id'] . '&t=1'); $download_link .= '&mode=view'; @@ -971,7 +970,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, // Windows Media Streams case ATTACHMENT_CATEGORY_WM: - $l_downloaded_viewed = 'VIEWED_COUNT'; // Giving the filename directly because within the wm object all variables are in local context making it impossible // to validate against a valid session (all params can differ) @@ -990,7 +988,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, // Real Media Streams case ATTACHMENT_CATEGORY_RM: case ATTACHMENT_CATEGORY_QUICKTIME: - $l_downloaded_viewed = 'VIEWED_COUNT'; $block_array += array( 'S_RM_FILE' => ($display_cat == ATTACHMENT_CATEGORY_RM) ? true : false, @@ -1007,8 +1004,6 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, case ATTACHMENT_CATEGORY_FLASH: list($width, $height) = @getimagesize($filename); - $l_downloaded_viewed = 'VIEWED_COUNT'; - $block_array += array( 'S_FLASH_FILE' => true, 'WIDTH' => $width, @@ -1021,7 +1016,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, break; default: - $l_downloaded_viewed = 'DOWNLOAD_COUNT'; + $l_downloaded_viewed = 'DOWNLOAD_COUNTS'; $block_array += array( 'S_FILE' => true, @@ -1029,11 +1024,14 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count, break; } - $l_download_count = (!isset($attachment['download_count']) || $attachment['download_count'] == 0) ? $user->lang[$l_downloaded_viewed . '_NONE'] : (($attachment['download_count'] == 1) ? sprintf($user->lang[$l_downloaded_viewed], $attachment['download_count']) : sprintf($user->lang[$l_downloaded_viewed . 'S'], $attachment['download_count'])); + if (!isset($attachment['download_count'])) + { + $attachment['download_count'] = 0; + } $block_array += array( 'U_DOWNLOAD_LINK' => $download_link, - 'L_DOWNLOAD_COUNT' => $l_download_count + 'L_DOWNLOAD_COUNT' => $user->lang($l_downloaded_viewed, (int) $attachment['download_count']), ); } diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 2b871a21ec..2ec34e1084 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -1043,10 +1043,10 @@ function display_user_activity(&$userdata) $template->assign_vars(array( 'ACTIVE_FORUM' => $active_f_name, - 'ACTIVE_FORUM_POSTS' => ($active_f_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_f_count), + 'ACTIVE_FORUM_POSTS' => $user->lang('USER_POSTS', (int) $active_f_count), 'ACTIVE_FORUM_PCT' => sprintf($l_active_pct, $active_f_pct), 'ACTIVE_TOPIC' => censor_text($active_t_name), - 'ACTIVE_TOPIC_POSTS' => ($active_t_count == 1) ? sprintf($user->lang['USER_POST'], 1) : sprintf($user->lang['USER_POSTS'], $active_t_count), + 'ACTIVE_TOPIC_POSTS' => $user->lang('USER_POSTS', (int) $active_t_count), 'ACTIVE_TOPIC_PCT' => sprintf($l_active_pct, $active_t_pct), 'U_ACTIVE_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $active_f_id), 'U_ACTIVE_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 't=' . $active_t_id), diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index d90e321285..76f25da977 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1330,7 +1330,7 @@ function get_folder_status($folder_id, $folder) 'percent' => ($user->data['message_limit']) ? (($user->data['message_limit'] > 0) ? round(($folder['num_messages'] / $user->data['message_limit']) * 100) : 100) : 0, ); - $return['message'] = sprintf($user->lang['FOLDER_STATUS_MSG'], $return['percent'], $return['cur'], $return['max']); + $return['message'] = $user->lang('FOLDER_STATUS_MSG', (int) $return['max'], $return['cur'], $return['percent']); return $return; } diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php index 8206a183f3..c823e0a0ee 100644 --- a/phpBB/includes/mcp/mcp_forum.php +++ b/phpBB/includes/mcp/mcp_forum.php @@ -132,7 +132,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info) 'PAGINATION' => generate_pagination($url . "&i=$id&action=$action&mode=$mode&sd=$sort_dir&sk=$sort_key&st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start), 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start), - 'TOTAL_TOPICS' => ($forum_topics == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $forum_topics), + 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics), )); // Grab icons diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php index ee74a04c91..4ae46f98a2 100644 --- a/phpBB/includes/mcp/mcp_front.php +++ b/phpBB/includes/mcp/mcp_front.php @@ -119,22 +119,9 @@ function mcp_front_view($id, $mode, $action) $template->assign_vars(array( 'S_HIDDEN_FIELDS' => $s_hidden_fields, 'S_MCP_QUEUE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue"), + 'L_UNAPPROVED_TOTAL' => $user->lang('UNAPPROVED_POSTS_TOTAL', (int) $total), + 'S_HAS_UNAPPROVED_POSTS'=> ($total != 0), )); - - if ($total == 0) - { - $template->assign_vars(array( - 'L_UNAPPROVED_TOTAL' => $user->lang['UNAPPROVED_POSTS_ZERO_TOTAL'], - 'S_HAS_UNAPPROVED_POSTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_UNAPPROVED_TOTAL' => ($total == 1) ? $user->lang['UNAPPROVED_POST_TOTAL'] : sprintf($user->lang['UNAPPROVED_POSTS_TOTAL'], $total), - 'S_HAS_UNAPPROVED_POSTS' => true) - ); - } } } @@ -220,20 +207,10 @@ function mcp_front_view($id, $mode, $action) } } - if ($total == 0) - { - $template->assign_vars(array( - 'L_REPORTS_TOTAL' => $user->lang['REPORTS_ZERO_TOTAL'], - 'S_HAS_REPORTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_REPORTS_TOTAL' => ($total == 1) ? $user->lang['REPORT_TOTAL'] : sprintf($user->lang['REPORTS_TOTAL'], $total), - 'S_HAS_REPORTS' => true) - ); - } + $template->assign_vars(array( + 'L_REPORTS_TOTAL' => $user->lang('REPORTS_TOTAL', (int) $total), + 'S_HAS_REPORTS' => ($total != 0), + )); } } @@ -313,20 +290,10 @@ function mcp_front_view($id, $mode, $action) } } - if ($total == 0) - { - $template->assign_vars(array( - 'L_PM_REPORTS_TOTAL' => $user->lang['PM_REPORTS_ZERO_TOTAL'], - 'S_HAS_PM_REPORTS' => false) - ); - } - else - { - $template->assign_vars(array( - 'L_PM_REPORTS_TOTAL' => ($total == 1) ? $user->lang['PM_REPORT_TOTAL'] : sprintf($user->lang['PM_REPORTS_TOTAL'], $total), - 'S_HAS_PM_REPORTS' => true) - ); - } + $template->assign_vars(array( + 'L_PM_REPORTS_TOTAL' => $user->lang('PM_REPORTS_TOTAL', (int) $total), + 'S_HAS_PM_REPORTS' => ($total != 0), + )); } // Latest 5 logs diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php index dc05ba4110..52f8259acf 100644 --- a/phpBB/includes/mcp/mcp_logs.php +++ b/phpBB/includes/mcp/mcp_logs.php @@ -174,7 +174,7 @@ class mcp_logs $template->assign_vars(array( 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), - 'TOTAL' => ($log_count == 1) ? $user->lang['TOTAL_LOG'] : sprintf($user->lang['TOTAL_LOGS'], $log_count), + 'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count), 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), 'L_TITLE' => $user->lang['MCP_LOGS'], diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php index dfb6ed3b68..1432e96a48 100644 --- a/phpBB/includes/mcp/mcp_notes.php +++ b/phpBB/includes/mcp/mcp_notes.php @@ -228,7 +228,7 @@ class mcp_notes 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination($this->u_action . "&$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start), - 'TOTAL_REPORTS' => ($log_count == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $log_count), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count), 'RANK_TITLE' => $rank_title, 'JOINED' => $user->format_date($userrow['user_regdate']), diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php index a8136b34df..6bba71f0d9 100644 --- a/phpBB/includes/mcp/mcp_pm_reports.php +++ b/phpBB/includes/mcp/mcp_pm_reports.php @@ -311,7 +311,7 @@ class mcp_pm_reports 'PAGINATION' => generate_pagination($this->u_action . "&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOTAL' => $total, - 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), ) ); diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index bd132c9ce8..692d29dabb 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -436,7 +436,7 @@ class mcp_queue 'PAGINATION' => generate_pagination($this->u_action . "&f=$forum_id&st=$sort_days&sk=$sort_key&sd=$sort_dir", $total, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, - 'TOTAL' => ($total == 1) ? (($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POST'] : $user->lang['VIEW_FORUM_TOPIC']) : sprintf((($mode == 'unapproved_posts') ? $user->lang['VIEW_TOPIC_POSTS'] : $user->lang['VIEW_FORUM_TOPICS']), $total), + 'TOTAL' => $user->lang((($mode == 'unapproved_posts') ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total), )); $this->tpl_name = 'mcp_queue'; diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index dac73b900f..eb2b655dd3 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -425,7 +425,7 @@ class mcp_reports 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start), 'TOPIC_ID' => $topic_id, 'TOTAL' => $total, - 'TOTAL_REPORTS' => ($total == 1) ? $user->lang['LIST_REPORT'] : sprintf($user->lang['LIST_REPORTS'], $total), + 'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total), ) ); diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index f080d78b1e..463dd5868d 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -336,7 +336,7 @@ function mcp_topic_view($id, $mode, $action) 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start), 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&t={$topic_info['topic_id']}&mode=$mode&action=$action&to_topic_id=$to_topic_id&posts_per_page=$posts_per_page&st=$sort_days&sk=$sort_key&sd=$sort_dir"), $total, $posts_per_page, $start), - 'TOTAL_POSTS' => ($total == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total), + 'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total), )); } diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 9339389ea4..8cf435c293 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -185,7 +185,7 @@ class mcp_warn 'PAGE_NUMBER' => on_page($user_count, $config['topics_per_page'], $start), 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&mode=list&st=$st&sk=$sk&sd=$sd"), $user_count, $config['topics_per_page'], $start), - 'TOTAL_USERS' => ($user_count == 1) ? $user->lang['LIST_USER'] : sprintf($user->lang['LIST_USERS'], $user_count), + 'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count), )); } diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index b3a48112ea..cb9a9d7d28 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -772,7 +772,7 @@ class bbcode_firstpass extends bbcode if ($config['max_quote_depth'] && sizeof($close_tags) >= $config['max_quote_depth']) { // there are too many nested quotes - $error_ary['quote_depth'] = sprintf($user->lang['QUOTE_DEPTH_EXCEEDED'], $config['max_quote_depth']); + $error_ary['quote_depth'] = $user->lang('QUOTE_DEPTH_EXCEEDED', (int) $config['max_quote_depth']); $out .= $buffer . $tok; $tok = '[]'; diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 4261a64169..0733e4f7fb 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -1821,6 +1821,9 @@ class user extends session * This function/functionality is inspired by SHS` and Ashe. * * Example call: <samp>$user->lang('NUM_POSTS_IN_QUEUE', 1);</samp> + * + * If the first parameter is an array, the parts are used as keys and subkeys to get the lang: + * Example: <samp>$user->lang(array('datetime', 'AGO'), 1)</samp> uses $user->lang['datetime']['AGO'] as lang. */ function lang() { diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 738da62158..3538b641f7 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -674,8 +674,8 @@ class ucp_main $template->assign_vars(array( 'PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start), - 'TOTAL_TOPICS' => ($topics_count == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $topics_count)) - ); + 'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count), + )); } if ($mode == 'subscribed') diff --git a/phpBB/includes/ucp/ucp_pm.php b/phpBB/includes/ucp/ucp_pm.php index 0691f3158c..6dbf092604 100644 --- a/phpBB/includes/ucp/ucp_pm.php +++ b/phpBB/includes/ucp/ucp_pm.php @@ -345,8 +345,8 @@ class ucp_pm 'NUM_NOT_MOVED' => $num_not_moved, 'NUM_REMOVED' => $num_removed, 'RELEASE_MESSAGE_INFO' => sprintf($user->lang['RELEASE_MESSAGES'], '<a href="' . $this->u_action . '&folder=' . $folder_id . '&release=1">', '</a>'), - 'NOT_MOVED_MESSAGES' => ($num_not_moved == 1) ? $user->lang['NOT_MOVED_MESSAGE'] : sprintf($user->lang['NOT_MOVED_MESSAGES'], $num_not_moved), - 'RULE_REMOVED_MESSAGES' => ($num_removed == 1) ? $user->lang['RULE_REMOVED_MESSAGE'] : sprintf($user->lang['RULE_REMOVED_MESSAGES'], $num_removed), + 'NOT_MOVED_MESSAGES' => $user->lang('NOT_MOVED_MESSAGES', (int) $num_not_moved), + 'RULE_REMOVED_MESSAGES' => $user->lang('RULE_REMOVED_MESSAGES', (int) $num_removed), 'S_FOLDER_OPTIONS' => $s_folder_options, 'S_TO_FOLDER_OPTIONS' => $s_to_folder_options, diff --git a/phpBB/includes/ucp/ucp_pm_options.php b/phpBB/includes/ucp/ucp_pm_options.php index 49c727847a..bd55e2c6c5 100644 --- a/phpBB/includes/ucp/ucp_pm_options.php +++ b/phpBB/includes/ucp/ucp_pm_options.php @@ -409,7 +409,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit $folder[PRIVMSGS_INBOX] = array( 'folder_name' => $user->lang['PM_INBOX'], - 'message_status' => sprintf($user->lang['FOLDER_MESSAGE_STATUS'], $num_messages, $user->data['message_limit']) + 'message_status' => $user->lang('FOLDER_MESSAGE_STATUS', (int) $user->data['message_limit'], $num_messages), ); $sql = 'SELECT folder_id, folder_name, pm_count @@ -423,7 +423,7 @@ function message_options($id, $mode, $global_privmsgs_rules, $global_rule_condit $num_user_folder++; $folder[$row['folder_id']] = array( 'folder_name' => $row['folder_name'], - 'message_status' => sprintf($user->lang['FOLDER_MESSAGE_STATUS'], $row['pm_count'], $user->data['message_limit']) + 'message_status' => $user->lang('FOLDER_MESSAGE_STATUS', (int) $user->data['message_limit'], $row['pm_count']), ); } $db->sql_freeresult($result); diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index c74574f361..7b850cb436 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -455,7 +455,7 @@ function get_pm_from($folder_id, $folder, $user_id) $template->assign_vars(array( 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&mode=view&action=view_folder&f=$folder_id&$u_sort_param"), $pm_count, $config['topics_per_page'], $start), 'PAGE_NUMBER' => on_page($pm_count, $config['topics_per_page'], $start), - 'TOTAL_MESSAGES' => (($pm_count == 1) ? $user->lang['VIEW_PM_MESSAGE'] : sprintf($user->lang['VIEW_PM_MESSAGES'], $pm_count)), + 'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count), 'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'), |