From b443b53919f50bd0176e7b67dfd1efc28276a770 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Thu, 18 Oct 2018 23:34:18 +0200 Subject: Translation: added pluralization support --- includes/controller/user_angeltypes_controller.php | 13 +++++++++---- includes/view/ShiftCalendarShiftRenderer.php | 6 ++---- includes/view/User_view.php | 5 +---- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'includes') diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index aa614cf3..734bd1e9 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -23,10 +23,15 @@ function user_angeltypes_unconfirmed_hint() . ''; } - return sprintf(ngettext('There is %d unconfirmed angeltype.', 'There are %d unconfirmed angeltypes.', - count($unconfirmed_user_angeltypes)), - count($unconfirmed_user_angeltypes)) . ' ' . __('Angel types which need approvals:') . ' ' . join(', ', - $unconfirmed_links); + $count = count($unconfirmed_user_angeltypes); + return _e( + 'There is %d unconfirmed angeltype.', + 'There are %d unconfirmed angeltypes.', + $count, + [$count] + ) + . ' ' . __('Angel types which need approvals:') + . ' ' . join(', ', $unconfirmed_links); } /** diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 9e40b1c6..80cea241 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -175,10 +175,8 @@ class ShiftCalendarShiftRenderer $angeltype, $shift_entries ); - $inner_text = sprintf( - ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()), - $shift_signup_state->getFreeEntries() - ); + $freeEntriesCount = $shift_signup_state->getFreeEntries(); + $inner_text = _e('%d helper needed', '%d helpers needed', $freeEntriesCount, [$freeEntriesCount]); switch ($shift_signup_state->getState()) { case ShiftSignupState::ADMIN: diff --git a/includes/view/User_view.php b/includes/view/User_view.php index fb541619..f8160765 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -727,10 +727,7 @@ function User_view_state_admin($freeloader, $user_source) if ($user_source['got_voucher'] > 0) { $state[] = '' . glyph('cutlery') - . sprintf( - ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']), - $user_source['got_voucher'] - ) + . _e('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher'], [$user_source['got_voucher']]) . ''; } else { $state[] = '' . __('Got no vouchers') . ''; -- cgit v1.3.1