hack plurals string for 'N member(s)'

This commit is contained in:
B. Petersen
2019-10-05 20:20:29 +02:00
parent 52bcbc344e
commit bdccf84bf5
2 changed files with 13 additions and 1 deletions
@@ -16,6 +16,7 @@ import org.thoughtcrime.securesms.components.AvatarImageView;
import org.thoughtcrime.securesms.connect.DcHelper;
import org.thoughtcrime.securesms.mms.GlideRequests;
import org.thoughtcrime.securesms.util.Prefs;
import org.thoughtcrime.securesms.util.Util;
import org.thoughtcrime.securesms.util.ViewUtil;
public class ConversationTitleView extends RelativeLayout {
@@ -124,9 +125,19 @@ public class ConversationTitleView extends RelativeLayout {
}
else {
this.title.setText(dcChat.getName());
this.subtitle.setText(dcChat.getSubtitle());
this.subtitle.setText(hackPluralsString(dcChat.getSubtitle()));
}
this.subtitle.setVisibility(showSubtitle? View.VISIBLE : View.GONE);
}
private String hackPluralsString(String string) {
// the rust-core does not care about plural forms (there is just once case that was not worth the effort up to now)
// therefore, we check if the returned string has the form "N member(s)" and localized the corrently to one/few/many/other
if( string.endsWith(" member(s)") ) {
int cnt = Util.objectToInt(string.substring(0, string.indexOf(" ")));
string = getContext().getResources().getQuantityString(R.plurals.n_members, cnt, cnt);
}
return string;
}
}
@@ -641,6 +641,7 @@ public class ApplicationDcContext extends DcContext {
case 1: s = context.getString(R.string.chat_no_messages); break;
case 2: s = context.getString(R.string.self); break;
case 3: s = context.getString(R.string.draft); break;
case 4: s = null; break; // we create DC_STR_MEMBER in hackPluralsString()
case 7: s = context.getString(R.string.voice_message); break;
case 8: s = context.getString(R.string.chat_contact_request); break;
case 9: s = context.getString(R.string.image); break;