Skip to:
Content

BuddyPress.org

Changeset 9765


Ignore:
Timestamp:
04/17/2015 01:27:06 PM (6 years ago)
Author:
boonebgorges
Message:

Improved plural forms for localizable strings.

Strings that are intended for use only in the case of a single item should not
be bundled with strings intended for use with plurals, as this pattern does not
work with languages that use the singular nominal form for numbers other than
one. See https://core.trac.wordpress.org/ticket/28502#comment:23.

This changeset also fixes a few places where a formatted string, rather than a
raw integer, was being passed as the $count value to _n().

Props SergeyBiryukov.
Fixes #6368.

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-activity/bp-activity-template.php

    r9751 r9765  
    848848        $total     = bp_core_number_format( $activities_template->total_activity_count );
    849849
    850         return sprintf( _n( 'Viewing 1 item', 'Viewing %1$s - %2$s of %3$s items', $total, 'buddypress' ), $from_num, $to_num, $total );
     850        if ( 1 == $activities_template->total_activity_count ) {
     851            $message = __( 'Viewing 1 item', 'buddypress' );
     852        } else {
     853            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s item', 'Viewing %1$s - %2$s of %3$s items', $activities_template->total_activity_count, 'buddypress' ), $from_num, $to_num, $total );
     854        }
     855
     856        return $message;
    851857    }
    852858
  • trunk/src/bp-blogs/bp-blogs-template.php

    r9471 r9765  
    473473    $total     = bp_core_number_format( $blogs_template->total_blog_count );
    474474
    475     echo sprintf( _n( 'Viewing 1 site', 'Viewing %1$s - %2$s of %3$s sites', $total, 'buddypress' ), $from_num, $to_num, $total );
     475    if ( 1 == $blogs_template->total_blog_count ) {
     476        $message = __( 'Viewing 1 site', 'buddypress' );
     477    } else {
     478        $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s site', 'Viewing %1$s - %2$s of %3$s sites', $blogs_template->total_blog_count, 'buddypress' ), $from_num, $to_num, $total );
     479    }
     480
     481    echo $message;
    476482}
    477483
  • trunk/src/bp-forums/bp-forums-template.php

    r9515 r9765  
    18791879            $pag_filter = sprintf( __( ' matching tag "%s"', 'buddypress' ), $forum_template->search_terms );
    18801880
     1881        if ( 1 == $forum_template->total_topic_count ) {
     1882            $message = __( 'Viewing 1 topic', 'buddypress' );
     1883        } else {
     1884            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s topic', 'Viewing %1$s - %2$s of %3$s topics', (int) $forum_template->total_topic_count, 'buddypress' ), $from_num, $to_num, $total, $pag_filter );
     1885        }
     1886
    18811887        /**
    18821888         * Filters the pagination count for the current topic list.
     
    18891895         * @param string $total    Total count of topics found.
    18901896         */
    1891         return apply_filters( 'bp_get_forum_pagination_count', sprintf( _n( 'Viewing 1 topic', 'Viewing %1$s - %2$s of %3$s topics', (int) $forum_template->total_topic_count, 'buddypress' ), $from_num, $to_num, $total, $pag_filter ), $from_num, $to_num, $total );
     1897        return apply_filters( 'bp_get_forum_pagination_count', $message, $from_num, $to_num, $total );
    18921898    }
    18931899
     
    26232629    $total = bp_core_number_format( $topic_template->total_post_count );
    26242630
     2631    if ( 1 == $topic_template->total_post_count ) {
     2632        $message = __( 'Viewing 1 post', 'buddypress' );
     2633    } else {
     2634        $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s post', 'Viewing %1$s - %2$s of %3$s posts', (int) $topic_template->total_post_count, 'buddypress' ), $from_num, $to_num, $total );
     2635    }
     2636
    26252637    /**
    26262638     * Filters the pagination count for the current topic page.
     
    26332645     * @param string $total    Total count of topics found.
    26342646     */
    2635     echo apply_filters( 'bp_the_topic_pagination_count', sprintf( _n( 'Viewing 1 post', 'Viewing %1$s - %2$s of %3$s posts', (int) $topic_template->total_post_count, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     2647    echo apply_filters( 'bp_the_topic_pagination_count', $message, $from_num, $to_num, $total );
    26362648}
    26372649
  • trunk/src/bp-groups/bp-groups-admin.php

    r9665 r9765  
    10401040    ) );
    10411041
    1042     $viewing_text = sprintf(
    1043         _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $query->total_users, 'buddypress' ),
    1044         number_format_i18n( $current_page_start ),
    1045         number_format_i18n( $current_page_end ),
    1046         (int) $query->total_users
    1047     );
     1042    if ( 1 == $query->total_users ) {
     1043        $viewing_text = __( 'Viewing 1 member', 'buddypress' );
     1044    } else {
     1045        $viewing_text = sprintf(
     1046            _n( 'Viewing %1$s - %2$s of %3$s member', 'Viewing %1$s - %2$s of %3$s members', $query->total_users, 'buddypress' ),
     1047            bp_core_number_format( $current_page_start ),
     1048            bp_core_number_format( $current_page_end ),
     1049            bp_core_number_format( $query->total_users )
     1050        );
     1051    }
    10481052
    10491053    $pagination .= '<span class="bp-group-admin-pagination-viewing">' . $viewing_text . '</span>';
  • trunk/src/bp-groups/bp-groups-template.php

    r9706 r9765  
    17941794        $total     = bp_core_number_format( $groups_template->total_group_count );
    17951795
     1796        if ( 1 == $groups_template->total_group_count ) {
     1797            $message = __( 'Viewing 1 group', 'buddypress' );
     1798        } else {
     1799            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s group', 'Viewing %1$s - %2$s of %3$s groups', $groups_template->total_group_count, 'buddypress' ), $from_num, $to_num, $total );
     1800        }
     1801
    17961802        /**
    17971803         * Filters the "Viewing x-y of z groups" pagination message.
     
    18041810         * @param string $total    Total amount of groups found.
    18051811         */
    1806         return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1 group', 'Viewing %1$s - %2$s of %3$s groups', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     1812        return apply_filters( 'bp_get_groups_pagination_count', $message, $from_num, $to_num, $total );
    18071813    }
    18081814
     
    41164122        $total     = bp_core_number_format( $members_template->total_member_count );
    41174123
     4124        if ( 1 == $members_template->total_member_count ) {
     4125            $message = __( 'Viewing 1 member', 'buddypress' );
     4126        } else {
     4127            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s member', 'Viewing %1$s - %2$s of %3$s groups', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     4128        }
     4129
    41184130        /**
    41194131         * Filters the "Viewing x-y of z members" pagination message.
     
    41264138         * @param string $total    Total amount of members found.
    41274139         */
    4128         return apply_filters( 'bp_get_group_member_pagination_count', sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     4140        return apply_filters( 'bp_get_group_member_pagination_count', $message, $from_num, $to_num, $total );
    41294141    }
    41304142
     
    52395251        $total     = bp_core_number_format( $requests_template->total_request_count );
    52405252
     5253        if ( 1 == $requests_template->total_request_count ) {
     5254            $message = __( 'Viewing 1 request', 'buddypress' );
     5255        } else {
     5256            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s request', 'Viewing %1$s - %2$s of %3$s requests', $requests_template->total_request_count, 'buddypress' ), $from_num, $to_num, $total );
     5257        }
     5258
    52415259        /**
    52425260         * Filters pagination count text for group membership requests.
     
    52465264         * @param string $value Pagination count text for group membership requests.
    52475265         */
    5248         return apply_filters( 'bp_get_group_requests_pagination_count', sprintf( _n( 'Viewing 1 request', 'Viewing %1$s - %2$s of %3$s requests', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     5266        return apply_filters( 'bp_get_group_requests_pagination_count', $message, $from_num, $to_num, $total );
    52495267    }
    52505268
     
    56095627        $total     = bp_core_number_format( $invites_template->total_invite_count );
    56105628
     5629        if ( 1 == $invites_template->total_invite_count ) {
     5630            $message = __( 'Viewing 1 invitation', 'buddypress' );
     5631        } else {
     5632            $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s invitation', 'Viewing %1$s - %2$s of %3$s invitations', $invites_template->total_invite_count, 'buddypress' ), $from_num, $to_num, $total );
     5633        }
     5634
    56115635        /** This filter is documented in bp-groups/bp-groups-template.php */
    5612         return apply_filters( 'bp_get_groups_pagination_count', sprintf( _n( 'Viewing 1 invitation', 'Viewing %1$s - %2$s of %3$s invitations', $total, 'buddypress' ), $from_num, $to_num, $total ), $from_num, $to_num, $total );
     5636        return apply_filters( 'bp_get_groups_pagination_count', $message, $from_num, $to_num, $total );
    56135637    }
    56145638
  • trunk/src/bp-members/bp-members-admin.php

    r9759 r9765  
    18951895            case 'delete' :
    18961896                $header_text = __( 'Delete Pending Accounts', 'buddypress' );
    1897                 $helper_text = _n( 'You are about to delete the following account:', 'You are about to delete the following accounts:', count( $signup_ids ), 'buddypress' );
     1897                if ( 1 == count( $signup_ids ) ) {
     1898                    $helper_text = __( 'You are about to delete the following account:', 'buddypress' );
     1899                } else {
     1900                    $helper_text = __( 'You are about to delete the following accounts:', 'buddypress' );
     1901                }
    18981902                break;
    18991903
    19001904            case 'activate' :
    19011905                $header_text = __( 'Activate Pending Accounts', 'buddypress' );
    1902                 $helper_text = _n( 'You are about to activate the following account:', 'You are about to activate the following accounts:', count( $signup_ids ), 'buddypress' );
     1906                if ( 1 == count( $signup_ids ) ) {
     1907                    $helper_text = __( 'You are about to activate the following account:', 'buddypress' );
     1908                } else {
     1909                    $helper_text = __( 'You are about to activate the following accounts:', 'buddypress' );
     1910                }
    19031911                break;
    19041912
    19051913            case 'resend' :
    19061914                $header_text = __( 'Resend Activation Emails', 'buddypress' );
    1907                 $helper_text = _n( 'You are about to resend an activation email to the following account:', 'You are about to resend activation emails to the following accounts:', count( $signup_ids ), 'buddypress' );
     1915                if ( 1 == count( $signup_ids ) ) {
     1916                    $helper_text = __( 'You are about to resend an activation email to the following account:', 'buddypress' );
     1917                } else {
     1918                    $helper_text = __( 'You are about to resend an activation email to the following accounts:', 'buddypress' );
     1919                }
    19081920                break;
    19091921        }
  • trunk/src/bp-members/bp-members-template.php

    r9723 r9765  
    632632        $total     = bp_core_number_format( $members_template->total_member_count );
    633633
    634         if ( 'active' == $members_template->type )
    635             $pag = sprintf( _n( 'Viewing 1 active member', 'Viewing %1$s - %2$s of %3$s active members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
    636         elseif ( 'popular' == $members_template->type )
    637             $pag = sprintf( _n( 'Viewing 1 member with friends', 'Viewing %1$s - %2$s of %3$s members with friends', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
    638         elseif ( 'online' == $members_template->type )
    639             $pag = sprintf( _n( 'Viewing 1 online member', 'Viewing %1$s - %2$s of %3$s online members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
    640         else
    641             $pag = sprintf( _n( 'Viewing 1 member', 'Viewing %1$s - %2$s of %3$s members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     634        if ( 'active' == $members_template->type ) {
     635            if ( 1 == $members_template->total_member_count ) {
     636                $pag = __( 'Viewing 1 active member', 'buddypress' );
     637            } else {
     638                $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s active member', 'Viewing %1$s - %2$s of %3$s active members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     639            }
     640        } elseif ( 'popular' == $members_template->type ) {
     641            if ( 1 == $members_template->total_member_count ) {
     642                $pag = __( 'Viewing 1 member with friends', 'buddypress' );
     643            } else {
     644                $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s member with friends', 'Viewing %1$s - %2$s of %3$s members with friends', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     645            }
     646        } elseif ( 'online' == $members_template->type ) {
     647            if ( 1 == $members_template->total_member_count ) {
     648                $pag = __( 'Viewing 1 online member', 'buddypress' );
     649            } else {
     650                $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s online member', 'Viewing %1$s - %2$s of %3$s online members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     651            }
     652        } else {
     653            if ( 1 == $members_template->total_member_count ) {
     654                $pag = __( 'Viewing 1 member', 'buddypress' );
     655            } else {
     656                $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s member', 'Viewing %1$s - %2$s of %3$s members', $members_template->total_member_count, 'buddypress' ), $from_num, $to_num, $total );
     657            }
     658        }
    642659
    643660        /**
  • trunk/src/bp-messages/bp-messages-template.php

    r9415 r9765  
    10871087    $total     = bp_core_number_format( $messages_template->total_thread_count );
    10881088
    1089     echo sprintf( _n( 'Viewing 1 message', 'Viewing %1$s - %2$s of %3$s messages', $total, 'buddypress' ), $from_num, $to_num, number_format_i18n( $total ) );
     1089    if ( 1 == $messages_template->total_thread_count ) {
     1090        $message = __( 'Viewing 1 message', 'buddypress' );
     1091    } else {
     1092        $message = sprintf( _n( 'Viewing %1$s - %2$s of %3$s message', 'Viewing %1$s - %2$s of %3$s messages', $messages_template->total_thread_count, 'buddypress' ), $from_num, $to_num, $total );
     1093    }
     1094
     1095    echo $message;
    10901096}
    10911097
  • trunk/src/bp-notifications/bp-notifications-template.php

    r9574 r9765  
    11851185        $to_num     = bp_core_number_format( ( $start_num + ( $query_loop->pag_num - 1 ) > $query_loop->total_notification_count ) ? $query_loop->total_notification_count : $start_num + ( $query_loop->pag_num - 1 ) );
    11861186        $total      = bp_core_number_format( $query_loop->total_notification_count );
    1187         $pag        = sprintf( _n( 'Viewing 1 notification', 'Viewing %1$s - %2$s of %3$s notifications', $total, 'buddypress' ), $from_num, $to_num, $total );
     1187
     1188        if ( 1 == $query_loop->total_notification_count ) {
     1189            $pag = __( 'Viewing 1 notification', 'buddypress' );
     1190        } else {
     1191            $pag = sprintf( _n( 'Viewing %1$s - %2$s of %3$s notification', 'Viewing %1$s - %2$s of %3$s notifications', $query_loop->total_notification_count, 'buddypress' ), $from_num, $to_num, $total );
     1192        }
    11881193
    11891194        /**
  • trunk/src/bp-templates/bp-legacy/buddypress/members/single/groups/invites.php

    r9604 r9765  
    1212                </div>
    1313
    14                 <h4><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a><span class="small"> - <?php printf( _nx( '1 member', '%d members', bp_get_group_total_members( false ),'Group member count', 'buddypress' ), bp_get_group_total_members( false )  ); ?></span></h4>
     14                <h4><a href="<?php bp_group_permalink(); ?>"><?php bp_group_name(); ?></a><span class="small"> - <?php printf( _nx( '%d member', '%d members', bp_get_group_total_members( false ),'Group member count', 'buddypress' ), bp_get_group_total_members( false )  ); ?></span></h4>
    1515
    1616                <p class="desc">
Note: See TracChangeset for help on using the changeset viewer.