Created
September 13, 2011 17:50
-
-
Save nickvergessen/1214498 to your computer and use it in GitHub Desktop.
Convert online user stuff to plural forms
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php | |
index 628f8ee..d39e773 100644 | |
--- a/phpBB/includes/functions.php | |
+++ b/phpBB/includes/functions.php | |
@@ -4161,59 +4161,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, | |
@@ -4434,10 +4401,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 = ''; | |
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php | |
index acd034c..be70095 100644 | |
--- a/phpBB/language/en/common.php | |
+++ b/phpBB/language/en/common.php | |
@@ -113,8 +113,11 @@ $lang = array_merge($lang, array( | |
'BOARD_DISABLED' => 'This board is currently disabled.', | |
'BOARD_UNAVAILABLE' => 'Sorry but the board is temporarily unavailable, please try again in a few minutes.', | |
'BROWSING_FORUM' => 'Users browsing this forum: %1$s', | |
- 'BROWSING_FORUM_GUEST' => 'Users browsing this forum: %1$s and %2$d guest', | |
- 'BROWSING_FORUM_GUESTS' => 'Users browsing this forum: %1$s and %2$d guests', | |
+ 'BROWSING_FORUM_GUESTS' => array( | |
+ 0 => 'Users browsing this forum: %2$s and %1$d guests', | |
+ 1 => 'Users browsing this forum: %2$s and %1$d guest', | |
+ 2 => 'Users browsing this forum: %2$s and %1$d guests', | |
+ ), | |
'BYTES' => 'Bytes', | |
'CANCEL' => 'Cancel', | |
@@ -243,12 +246,16 @@ $lang = array_merge($lang, array( | |
'GROUP_ERR_USERNAME' => 'No group name specified.', | |
'GROUP_ERR_USER_LONG' => 'Group names cannot exceed 60 characters. The specified group name is too long.', | |
'GUEST' => 'Guest', | |
- 'GUEST_USERS_ONLINE' => 'There are %d guest users online', | |
- 'GUEST_USERS_TOTAL' => '%d guests', | |
- 'GUEST_USERS_ZERO_ONLINE' => 'There are 0 guest users online', | |
- 'GUEST_USERS_ZERO_TOTAL' => '0 guests', | |
- 'GUEST_USER_ONLINE' => 'There is %d guest user online', | |
- 'GUEST_USER_TOTAL' => '%d guest', | |
+ 'GUEST_USERS_ONLINE' => array( | |
+ 0 => 'There are 0 guest users online', | |
+ 1 => 'There is %d guest user online', | |
+ 2 => 'There are %d guest users online', | |
+ ), | |
+ 'GUEST_USERS_TOTAL' => array( | |
+ 0 => '%d guests', | |
+ 1 => '%d guest', | |
+ 2 => '%d guests', | |
+ ), | |
'G_ADMINISTRATORS' => 'Administrators', | |
'G_BOTS' => 'Bots', | |
'G_GUESTS' => 'Guests', | |
@@ -257,15 +264,16 @@ $lang = array_merge($lang, array( | |
'G_GLOBAL_MODERATORS' => 'Global moderators', | |
'G_NEWLY_REGISTERED' => 'Newly registered users', | |
- 'HIDDEN_USERS_ONLINE' => '%d hidden users online', | |
- 'HIDDEN_USERS_TOTAL' => '%d hidden', | |
- 'HIDDEN_USERS_TOTAL_AND' => '%d hidden and ', | |
- 'HIDDEN_USERS_ZERO_ONLINE' => '0 hidden users online', | |
- 'HIDDEN_USERS_ZERO_TOTAL' => '0 hidden', | |
- 'HIDDEN_USERS_ZERO_TOTAL_AND' => '0 hidden and ', | |
- 'HIDDEN_USER_ONLINE' => '%d hidden user online', | |
- 'HIDDEN_USER_TOTAL' => '%d hidden', | |
- 'HIDDEN_USER_TOTAL_AND' => '%d hidden and ', | |
+ 'HIDDEN_USERS_ONLINE' => array( | |
+ 0 => '%d hidden users', | |
+ 1 => '%d hidden user', | |
+ 2 => '%d hidden users', | |
+ ), | |
+ 'HIDDEN_USERS_TOTAL' => array( | |
+ 0 => '%d hidden', | |
+ 1 => '%d hidden', | |
+ 2 => '%d hidden', | |
+ ), | |
'HIDE_GUESTS' => 'Hide guests', | |
'HIDE_ME' => 'Hide my online status this session', | |
'HOURS' => 'Hours', | |
@@ -419,9 +427,18 @@ $lang = array_merge($lang, array( | |
'OFFLINE' => 'Offline', | |
'ONLINE' => 'Online', | |
'ONLINE_BUDDIES' => 'Online friends', | |
- 'ONLINE_USERS_TOTAL' => 'In total there are <strong>%d</strong> users online :: ', | |
- 'ONLINE_USERS_ZERO_TOTAL' => 'In total there are <strong>0</strong> users online :: ', | |
- 'ONLINE_USER_TOTAL' => 'In total there is <strong>%d</strong> user online :: ', | |
+ // "... :: x registered and y hidden" | |
+ 'ONLINE_USERS_TOTAL' => array( | |
+ 0 => 'In total there are <strong>%1$d</strong> users online :: %2$s and %3$s', | |
+ 1 => 'In total there is <strong>%1$d</strong> user online :: %2$s and %3$s', | |
+ 2 => 'In total there are <strong>%1$d</strong> users online :: %2$s and %3$s', | |
+ ), | |
+ // "... :: x registered, y hidden and z guests" | |
+ 'ONLINE_USERS_TOTAL_GUESTS' => array( | |
+ 0 => 'In total there are <strong>%1$d</strong> users online :: %2$s, %3$s and %4$s', | |
+ 1 => 'In total there is <strong>%1$d</strong> user online :: %2$s, %3$s and %4$s', | |
+ 2 => 'In total there are <strong>%1$d</strong> users online :: %2$s, %3$s and %4$s', | |
+ ), | |
'OPTIONS' => 'Options', | |
'PAGE_OF' => 'Page <strong>%1$d</strong> of <strong>%2$d</strong>', | |
@@ -474,15 +491,17 @@ $lang = array_merge($lang, array( | |
'REDIRECTS' => 'Total redirects', | |
'REGISTER' => 'Register', | |
'REGISTERED_USERS' => 'Registered users:', | |
- 'REG_USERS_ONLINE' => 'There are %d registered users and ', | |
- 'REG_USERS_TOTAL' => '%d registered, ', | |
- 'REG_USERS_TOTAL_AND' => '%d registered and ', | |
- 'REG_USERS_ZERO_ONLINE' => 'There are 0 registered users and ', | |
- 'REG_USERS_ZERO_TOTAL' => '0 registered, ', | |
- 'REG_USERS_ZERO_TOTAL_AND' => '0 registered and ', | |
- 'REG_USER_ONLINE' => 'There is %d registered user and ', | |
- 'REG_USER_TOTAL' => '%d registered, ', | |
- 'REG_USER_TOTAL_AND' => '%d registered and ', | |
+ // "... and 2 hidden users online" | |
+ 'REG_USERS_ONLINE' => array( | |
+ 0 => 'There are %1$d registered users and %2$s online', | |
+ 1 => 'There is %1$d registered user and %2$s online', | |
+ 2 => 'There are %1$d registered users and %2$s online', | |
+ ), | |
+ 'REG_USERS_TOTAL' => array( | |
+ 0 => '%d registered', | |
+ 1 => '%d registered', | |
+ 2 => '%d registered', | |
+ ), | |
'REMOVE' => 'Remove', | |
'REMOVE_INSTALL' => 'Please delete, move or rename the install directory before you use your board. If this directory is still present, only the Administration Control Panel (ACP) will be accessible.', | |
'REPLIES' => 'Replies', | |
@@ -645,8 +664,11 @@ $lang = array_merge($lang, array( | |
'TOPIC_REPORTED' => 'This topic has been reported', | |
'TOTAL_TOPICS_OTHER'=> 'Total topics <strong>%d</strong>', | |
'TOTAL_TOPICS_ZERO' => 'Total topics <strong>0</strong>', | |
- 'TOTAL_USERS_OTHER' => 'Total members <strong>%d</strong>', | |
- 'TOTAL_USERS_ZERO' => 'Total members <strong>0</strong>', | |
+ 'TOTAL_USERS' => array( | |
+ 0 => 'Total members <strong>0</strong>', | |
+ 1 =>'Total members <strong>%d</strong>', | |
+ 2 =>'Total members <strong>%d</strong>', | |
+ ), | |
'TRACKED_PHP_ERROR' => 'Tracked PHP errors: %s', | |
'UNABLE_GET_IMAGE_SIZE' => 'It was not possible to determine the dimensions of the image.', | |
@@ -696,8 +718,11 @@ $lang = array_merge($lang, array( | |
'VIEW_LATEST_POST' => 'View the latest post', | |
'VIEW_NEWEST_POST' => 'View first unread post', | |
'VIEW_NOTES' => 'View user notes', | |
- 'VIEW_ONLINE_TIME' => 'based on users active over the past %d minute', | |
- 'VIEW_ONLINE_TIMES' => 'based on users active over the past %d minutes', | |
+ 'VIEW_ONLINE_TIMES' => array( | |
+ 0 => 'based on users active over the past %d minutes', | |
+ 1 => 'based on users active over the past %d minute', | |
+ 2 => 'based on users active over the past %d minutes', | |
+ ), | |
'VIEW_TOPIC' => 'View topic', | |
'VIEW_TOPIC_ANNOUNCEMENT' => 'Announcement: ', | |
'VIEW_TOPIC_GLOBAL' => 'Global Announcement: ', | |
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php | |
index 5eb2894..966402d 100644 | |
--- a/phpBB/viewonline.php | |
+++ b/phpBB/viewonline.php | |
@@ -343,32 +343,6 @@ while ($row = $db->sql_fetchrow($result)) | |
$db->sql_freeresult($result); | |
unset($prev_id, $prev_ip); | |
-// Generate reg/hidden/guest online text | |
-$vars_online = array( | |
- 'REG' => array('logged_visible_online', 'l_r_user_s'), | |
- 'HIDDEN'=> array('logged_hidden_online', 'l_h_user_s'), | |
- 'GUEST' => array('guest_counter', 'l_g_user_s') | |
-); | |
- | |
-foreach ($vars_online as $l_prefix => $var_ary) | |
-{ | |
- switch ($$var_ary[0]) | |
- { | |
- case 0: | |
- $$var_ary[1] = $user->lang[$l_prefix . '_USERS_ZERO_ONLINE']; | |
- break; | |
- | |
- case 1: | |
- $$var_ary[1] = $user->lang[$l_prefix . '_USER_ONLINE']; | |
- break; | |
- | |
- default: | |
- $$var_ary[1] = $user->lang[$l_prefix . '_USERS_ONLINE']; | |
- break; | |
- } | |
-} | |
-unset($vars_online); | |
- | |
$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&sk=$sort_key&sd=$sort_dir"), $counter, $config['topics_per_page'], $start); | |
// Grab group details for legend display | |
@@ -414,8 +388,8 @@ meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_gue | |
// Send data to template | |
$template->assign_vars(array( | |
- 'TOTAL_REGISTERED_USERS_ONLINE' => sprintf($l_r_user_s, $logged_visible_online) . sprintf($l_h_user_s, $logged_hidden_online), | |
- 'TOTAL_GUEST_USERS_ONLINE' => sprintf($l_g_user_s, $guest_counter), | |
+ 'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)), | |
+ 'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter), | |
'LEGEND' => $legend, | |
'PAGINATION' => $pagination, | |
'PAGE_NUMBER' => on_page($counter, $config['topics_per_page'], $start), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment