Improve string by adding plurals

This commit is contained in:
M M Arif
2022-05-05 18:45:04 +05:00
parent a09a30960b
commit 40811e9f73
2 changed files with 6 additions and 2 deletions

View File

@@ -163,7 +163,8 @@ public class UserAccountsAdapter extends RecyclerView.Adapter<UserAccountsAdapte
assert notificationCount != null;
if(notificationCount.getNew() > 0) {
new Handler().postDelayed(() -> Toasty.info(context, context.getString(R.string.youHaveNewNotifications, String.valueOf(notificationCount.getNew()))), 5000);
String toastMsg = context.getResources().getQuantityString(R.plurals.youHaveNewNotifications, Math.toIntExact(notificationCount.getNew()), Math.toIntExact(notificationCount.getNew()));
new Handler().postDelayed(() -> Toasty.info(context, toastMsg), 5000);
}
}
}

View File

@@ -653,7 +653,10 @@
<string name="mainNotificationChannelName">Notifications</string>
<string name="mainNotificationChannelDescription">This is the main notification channel of GitNex.</string>
<string name="notificationExtraInfo" translatable="false">- %s (%s)</string>
<string name="youHaveNewNotifications">You have %s notification(s).</string>
<plurals name="youHaveNewNotifications">
<item quantity="one">You have %s new notification.</item>
<item quantity="other">You have %s new notifications.</item>
</plurals>
<string name="isRead">Read</string>
<string name="isUnread">Unread</string>