Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Fix some plural messages #1934

Merged
merged 2 commits into from
Mar 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions vector/src/main/java/im/vector/activity/VectorRoomActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2646,11 +2646,7 @@ public void onClick(View v) {
iconId = R.drawable.newmessages;
textColor = ContextCompat.getColor(VectorRoomActivity.this, R.color.vector_fuchsia_color);

if (unreadCount == 1) {
text = new SpannableString(getResources().getString(R.string.room_new_message_notification));
} else {
text = new SpannableString(getResources().getString(R.string.room_new_messages_notification, unreadCount));
}
text = new SpannableString(getResources().getQuantityString(R.plurals.room_new_messages_notification, unreadCount, unreadCount));
} else {
iconId = R.drawable.scrolldown;
textColor = ThemeUtils.getColor(this, R.attr.room_notification_text_color);
Expand Down Expand Up @@ -3082,9 +3078,9 @@ private void updateRoomHeaderMembersStatus() {
if (joinedMembersCount == 1) {
text = getResources().getString(R.string.room_title_one_member);
} else if (null != sRoomPreviewData) {
text = getResources().getString(R.string.room_title_members, joinedMembersCount);
text = getResources().getQuantityString(R.plurals.room_title_members, joinedMembersCount, joinedMembersCount);
} else {
text = getString(R.string.room_header_active_members, activeMembersCount, joinedMembersCount);
text = getQuantityString(R.plurals.room_header_active_members, joinedMembersCount, joinedMembersCount, activeMembersCount);
}

if (!TextUtils.isEmpty(text)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,15 +723,13 @@ public View getChildView(int groupPosition, int childPosition, boolean isLastChi
value = "> " + PublicRoomsManager.PUBLIC_ROOMS_LIMIT;
}

roomMsgTxtView.setText(mContext.getResources().getString(R.string.directory_search_rooms_for, value, mSearchedPattern));
roomMsgTxtView.setText(mContext.getResources().getQuantityString(R.plurals.directory_search_rooms_for, PublicRoomsManager.PUBLIC_ROOMS_LIMIT, value, mSearchedPattern));
}
} else {
if (null == mPublicRoomsCount) {
roomMsgTxtView.setText(null);
} else if (mPublicRoomsCount > 1) {
roomMsgTxtView.setText(mContext.getResources().getString(R.string.directory_search_rooms, mPublicRoomsCount));
} else {
roomMsgTxtView.setText(mContext.getResources().getString(R.string.directory_search_room, mPublicRoomsCount));
roomMsgTxtView.setText(mContext.getResources().getQuantityString(R.plurals.directory_search_rooms, mPublicRoomsCount, mPublicRoomsCount));
}
}

Expand Down
2 changes: 1 addition & 1 deletion vector/src/main/java/im/vector/util/EventGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,6 @@ public List<MessageRow> getAvatarRows(int maxCount) {
}

public java.lang.String toString(Context context) {
return context.getString(R.string.membership_changes, mRowsMap.size());
return context.getQuantityString(R.plurals.membership_changes, mRowsMap.size(), mRowsMap.size());
}
}
2 changes: 1 addition & 1 deletion vector/src/main/java/im/vector/util/VectorUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ public int compare(RoomMember m1, RoomMember m2) {
displayName = context.getString(R.string.room_displayname_two_members, roomState.getMemberName(member1.getUserId()), roomState.getMemberName(member2.getUserId()));
} else {
RoomMember member = othersActiveMembers.get(0);
displayName = context.getString(R.string.room_displayname_more_than_two_members, roomState.getMemberName(member.getUserId()), othersActiveMembers.size() - 1);
displayName = context.getQuantityString(R.plurals.room_displayname_more_than_two_members, othersActiveMembers.size() - 1, othersActiveMembers.size() - 1, roomState.getMemberName(member.getUserId()));
}

return displayName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ private void refresh() {
firstWidget = mActiveWidgets.get(0);
mWidgetTypeTextView.setText(firstWidget.getHumanName());
} else if (mActiveWidgets.size() > 1) {
mWidgetTypeTextView.setText(mContext.getString(R.string.active_widgets, mActiveWidgets.size()));
mWidgetTypeTextView.setText(mContext.getQuantityString(R.plurals.active_widgets, mActiveWidgets.size(), mActiveWidgets.size()));
}

if (null != mUpdateListener) {
Expand Down
55 changes: 45 additions & 10 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@
<string name="groups_list">Groups List</string>

<!-- Mels -->
<string name="membership_changes">%d membership changes</string>
<plurals name="membership_changes">
<item quantity="one">1 membership change</item>
<item quantity="other">%d membership changes</item>
</plurals>

<!-- accounts list Screen -->

Expand Down Expand Up @@ -327,8 +330,14 @@
<!-- Chat creation -->
<string name="room_creation_title">New Chat</string>
<string name="room_creation_add_member">Add member</string>
<string name="room_header_active_members">%1$d/%2$d active members</string>
<string name="room_title_members">%1$d members</string>
<plurals name="room_header_active_members">
<item quantity="one">%2$d/1 active members</item>
<item quantity="other">%2$d/%d active members</item>
</plurals>
<plurals name="room_title_members">
<item quantity="one">1 member</item>
<item quantity="other">%d members</item>
</plurals>
<string name="room_title_one_member">1 member</string>
<string name="room_e2e_alert_title">Warning!</string>
<string name="room_e2e_alert_message">End-to-end encryption is in beta and may not be reliable.\n\nYou should not yet trust it to secure data.\n\nDevices will not yet be able to decrypt history from before they joined the room.\n\nEncrypted messages will not be visible on clients that do not yet implement encryption.</string>
Expand Down Expand Up @@ -402,7 +411,10 @@
<string name="room_message_file_not_found">File not found</string>
<string name="room_do_not_have_permission_to_post">You do not have permission to post to this room</string>
<string name="room_new_message_notification">1 new message</string>
<string name="room_new_messages_notification">%1$d new messages</string>
<plurals name="room_new_messages_notification">
<item quantity="one">1 new message</item>
<item quantity="other">%d new messages</item>
</plurals>

<!-- unrecognized SSL certificate -->
<string name="ssl_trust">Trust</string>
Expand Down Expand Up @@ -438,7 +450,10 @@
<string name="room_displayname_invite_from">Invite from %s</string>
<string name="room_displayname_room_invite">Room Invite</string>
<string name="room_displayname_two_members">%1$s and %2$s</string>
<string name="room_displayname_more_than_two_members">%1$s and %2$d others</string>
<plurals name="room_displayname_more_than_two_members">
<item quantity="one">%2$s and 1 other</item>
<item quantity="other">%2$s and %d others</item>
</plurals>
<string name="room_displayname_no_title">Empty room</string>

<!-- Search -->
Expand Down Expand Up @@ -466,9 +481,15 @@
<!-- Directory -->
<string name="directory_search_results_title">Browse directory</string>
<string name="directory_search_room">%1$d room</string>
<string name="directory_search_rooms">%1$d rooms</string>
<plurals name="directory_search_rooms">
<item quantity="one">1 room</item>
<item quantity="other">%d rooms</item>
</plurals>
<string name="directory_search_room_for">%1$d room found for %2$s</string>
<string name="directory_search_rooms_for">%1$s rooms found for %2$s</string>
<plurals name="directory_search_rooms_for">
<item quantity="one">%1$s room found for %2$s</item>
<item quantity="other">%1$s rooms found for %2$s</item>
</plurals>
<string name="directory_searching_title">Searching directory..</string>

<!-- home room settings -->
Expand Down Expand Up @@ -778,8 +799,19 @@
<string name="directory_server_native_rooms">All native %s rooms</string>

<!-- Notifications -->
<string name="notification_unread_notified_messages">%d unread notified messages</string>
<string name="notification_unread_notified_messages_in_room">%1$d unread notified messages in %2$d rooms"</string>
<plurals name="notification_unread_notified_messages">
<item quantity="one">1 unread notified message</item>
<item quantity="other">%d unread notified messages</item>
</plurals>
<plurals name="notification_unread_notified_messages_in_room_msgs">
<item quantity="one">1 unread notified message</item>
<item quantity="other">%d unread notified messages</item>
</plurals>
<plurals name="notification_unread_notified_messages_in_room_rooms">
<item quantity="one">1 room</item>
<item quantity="other">%d rooms</item>
</plurals>
<string name="notification_unread_notified_messages_in_room">%1$s in %2$s"</string>

<!-- historical -->
<string name="historical_placeholder">Search for historical</string>
Expand All @@ -801,7 +833,10 @@
<string name="event_formatter_widget_removed">%1$s removed by %2$s</string>
<string name="settings_labs_create_conference_with_jitsi">Create conference calls with jitsi</string>
<string name="widget_delete_message_confirmation">Are you sure you want to delete the widget?</string>
<string name="active_widgets">%1$d active widgets</string>
<plurals name="active_widgets">
<item quantity="one">1 active widget</item>
<item quantity="other">%d active widgets</item>
</plurals>

// Widget Integration Manager
<string name="widget_integration_unable_to_create">Unable to create widget.</string>
Expand Down