Pluralize some strings.

This commit is contained in:
Greyson Parrelli 2023-05-16 10:15:24 -04:00
parent 8df0248d4f
commit 5c5b88ebcc
4 changed files with 30 additions and 6 deletions

View file

@ -179,7 +179,7 @@ public class CameraContactSelectionFragment extends LoggingFragment implements C
if (error == null) return;
if (error == CameraContactSelectionViewModel.Error.MAX_SELECTION) {
String message = getString(R.string.CameraContacts_you_can_share_with_a_maximum_of_n_conversations, CameraContactSelectionViewModel.MAX_SELECTION_COUNT);
String message = getResources().getQuantityString(R.plurals.CameraContacts_you_can_share_with_a_maximum_of_n_conversations, CameraContactSelectionViewModel.MAX_SELECTION_COUNT, CameraContactSelectionViewModel.MAX_SELECTION_COUNT);
Toast.makeText(requireContext(), message, Toast.LENGTH_SHORT).show();
}
});

View file

@ -281,7 +281,7 @@ object NotificationFactory {
setContentTitle(context.getString(R.string.app_name))
setContentIntent(NotificationPendingIntentHelper.getActivity(context, 0, MainActivity.clearTop(context), PendingIntentFlags.mutable()))
setGroupSummary(true)
setSubText(context.getString(R.string.MessageNotifier_d_new_messages_in_d_conversations, state.messageCount, state.threadCount))
setSubText(context.buildSummaryString(state.messageCount, state.threadCount))
setContentInfo(state.messageCount.toString())
setNumber(state.messageCount)
setSummaryContentText(state.mostRecentSender)
@ -300,6 +300,12 @@ object NotificationFactory {
NotificationManagerCompat.from(context).safelyNotify(null, NotificationIds.MESSAGE_SUMMARY, builder.build())
}
private fun Context.buildSummaryString(messageCount: Int, threadCount: Int): String {
val messageString = resources.getQuantityString(R.plurals.MessageNotifier_d_messages, messageCount, messageCount)
val threadString = resources.getQuantityString(R.plurals.MessageNotifier_d_chats, threadCount, threadCount)
return getString(R.string.MessageNotifier_s_in_s, messageString, threadString)
}
private fun notifyInThread(context: Context, recipient: Recipient, lastAudibleNotification: Long) {
if (!SignalStore.settings().isMessageNotificationsInChatSoundsEnabled ||
ServiceUtil.getAudioManager(context).ringerMode != AudioManager.RINGER_MODE_NORMAL ||

View file

@ -276,7 +276,7 @@ public class StoragePreferenceFragment extends ListSummaryPreferenceFragment {
if (newTrimLength > 0 && (!trimLengthEnabled || newTrimLength < trimLength)) {
new MaterialAlertDialogBuilder(activity)
.setTitle(R.string.preferences_storage__delete_older_messages)
.setMessage(activity.getString(R.string.preferences_storage__this_will_permanently_trim_all_conversations_to_the_d_most_recent_messages, NumberFormat.getInstance().format(newTrimLength)))
.setMessage(activity.getResources().getQuantityString(R.plurals.preferences_storage__this_will_permanently_trim_all_conversations_to_the_d_most_recent_messages, newTrimLength, newTrimLength))
.setPositiveButton(R.string.delete, (d, w) -> updateTrimByLength(newTrimLength))
.setNegativeButton(android.R.string.cancel, null)
.show();

View file

@ -183,7 +183,11 @@
<string name="CameraContacts_recent_contacts">Recent contacts</string>
<string name="CameraContacts_signal_contacts">Signal contacts</string>
<string name="CameraContacts_signal_groups">Signal groups</string>
<string name="CameraContacts_you_can_share_with_a_maximum_of_n_conversations">You can share with a maximum of %d chats.</string>
<!-- A warning shown in a toast when -->
<plurals name="CameraContacts_you_can_share_with_a_maximum_of_n_conversations">
<item quantity="one">You can share with a maximum of %d chat.</item>
<item quantity="other">You can share with a maximum of %d chats.</item>
</plurals>
<string name="CameraContacts_select_signal_recipients">Select Signal recipients</string>
<string name="CameraContacts_no_signal_contacts">No Signal contacts</string>
<string name="CameraContacts_you_can_only_use_the_camera_button">You can only use the camera button to send photos to Signal contacts. </string>
@ -2159,7 +2163,18 @@
<string name="MediaPreviewFragment_read_more_overflow_text">Read More</string>
<!-- MessageNotifier -->
<!-- Text shown in a system notification that is used to summarize your notification. The first placeholder is the new message count, and the second placeholder represents the number of unique chats those message appear in. -->
<!-- Text shown in a system notification that is used to summarize your notification. The first placeholder is a pluralized string that describes how many messages (e.g. "3 messages"), and the second placeholder is a pluralized string that describes the number of unique chats those message appear in (e.g. "2 chats"). -->
<string name="MessageNotifier_s_in_s">%1$s in %2$s</string>
<!-- Text shown in a system notification that is used to summary how many messages you received. -->
<plurals name="MessageNotifier_d_messages">
<item quantity="one">%1$d message</item>
<item quantity="other">%1$d messages</item>
</plurals>
<!-- Text shown in a system notification that is used to summary how many chats have new messages. -->
<plurals name="MessageNotifier_d_chats">
<item quantity="one">%1$d chats</item>
<item quantity="other">%1$d chats</item>
</plurals>
<string name="MessageNotifier_d_new_messages_in_d_conversations">%1$d new messages in %2$d chats</string>
<string name="MessageNotifier_most_recent_from_s">Most recent from: %1$s</string>
<string name="MessageNotifier_locked_message">Locked message</string>
@ -2905,7 +2920,10 @@
<string name="preferences_storage__clear_message_history">Clear message history?</string>
<string name="preferences_storage__this_will_permanently_delete_all_message_history_and_media">This will permanently delete all message history and media from your device that are older than %1$s.</string>
<!-- The body of an alert dialog that is shown when confirming a trim operation. Trimming will delete all but the most recent messages in a chat. The placeholder represents how many messages are kept in each chat. All older messages are deleted. -->
<string name="preferences_storage__this_will_permanently_trim_all_conversations_to_the_d_most_recent_messages">This will permanently trim all chats to the %1$s most recent messages.</string>
<plurals name="preferences_storage__this_will_permanently_trim_all_conversations_to_the_d_most_recent_messages">
<item quantity="one">This will permanently trim all chats to the most recent message.</item>
<item quantity="other">This will permanently trim all chats to the %1$s most recent messages.</item>
</plurals>
<string name="preferences_storage__this_will_delete_all_message_history_and_media_from_your_device">This will permanently delete all message history and media from your device.</string>
<string name="preferences_storage__are_you_sure_you_want_to_delete_all_message_history">Are you sure you want to delete all message history?</string>
<string name="preferences_storage__all_message_history_will_be_permanently_removed_this_action_cannot_be_undone">All message history will be permanently removed. This action cannot be undone.</string>