fix some plurals

Closes #4815
Fixes #4811
// FREEBIE
This commit is contained in:
Christian Ascheberg 2015-12-05 17:27:09 +01:00 committed by Moxie Marlinspike
parent 49f60971bd
commit 08b61572e9
4 changed files with 25 additions and 14 deletions

View File

@ -9,9 +9,15 @@
<!-- ApplicationPreferencesActivity --> <!-- ApplicationPreferencesActivity -->
<string name="ApplicationPreferencesActivity_currently_s">Currently: %s</string> <string name="ApplicationPreferencesActivity_currently_s">Currently: %s</string>
<string name="ApplicationPreferenceActivity_you_havent_set_a_passphrase_yet">You haven\'t set a passphrase yet!</string> <string name="ApplicationPreferenceActivity_you_havent_set_a_passphrase_yet">You haven\'t set a passphrase yet!</string>
<string name="ApplicationPreferencesActivity_messages_per_conversation">%s messages per conversation</string> <plurals name="ApplicationPreferencesActivity_messages_per_conversation">
<item quantity="one">1 message per conversation</item>
<item quantity="other">%d messages per conversation</item>
</plurals>
<string name="ApplicationPreferencesActivity_delete_all_old_messages_now">Delete all old messages now?</string> <string name="ApplicationPreferencesActivity_delete_all_old_messages_now">Delete all old messages now?</string>
<string name="ApplicationPreferencesActivity_this_will_immediately_trim_all_conversations_to_the_s_most_recent_messages">This will immediately trim all conversations to the %s most recent messages.</string> <plurals name="ApplicationPreferencesActivity_this_will_immediately_trim_all_conversations_to_the_d_most_recent_messages">
<item quantity="one">This will immediately trim all conversations to the most recent message.</item>
<item quantity="other">This will immediately trim all conversations to the %d most recent messages.</item>
</plurals>
<string name="ApplicationPreferencesActivity_delete">Delete</string> <string name="ApplicationPreferencesActivity_delete">Delete</string>
<string name="ApplicationPreferencesActivity_disable_passphrase">Disable passphrase?</string> <string name="ApplicationPreferencesActivity_disable_passphrase">Disable passphrase?</string>
<string name="ApplicationPreferencesActivity_disable_lock_screen"> <string name="ApplicationPreferencesActivity_disable_lock_screen">
@ -34,7 +40,10 @@
<string name="ApplicationPreferencesActivity_sms_mms_summary">SMS %1$s, MMS %2$s</string> <string name="ApplicationPreferencesActivity_sms_mms_summary">SMS %1$s, MMS %2$s</string>
<!-- AppProtectionPreferenceFragment --> <!-- AppProtectionPreferenceFragment -->
<string name="AppProtectionPreferenceFragment_minutes">%d minutes</string> <plurals name="AppProtectionPreferenceFragment_minutes">
<item quantity="one">1 minute</item>
<item quantity="other">%d minutes</item>
</plurals>
<!-- DraftDatabase --> <!-- DraftDatabase -->
<string name="DraftDatabase_Draft_image_snippet">(image)</string> <string name="DraftDatabase_Draft_image_snippet">(image)</string>
@ -109,8 +118,10 @@
<string name="ConversationActivity_group_members">Group members</string> <string name="ConversationActivity_group_members">Group members</string>
<string name="ConversationActivity_group_conversation">Group conversation</string> <string name="ConversationActivity_group_conversation">Group conversation</string>
<string name="ConversationActivity_unnamed_group">Unnamed group</string> <string name="ConversationActivity_unnamed_group">Unnamed group</string>
<string name="ConversationActivity_d_recipients_in_group">%d members</string> <plurals name="ConversationActivity_d_recipients_in_group">
<string name="ConversationActivity_d_recipients_in_group_singular">1 member</string> <item quantity="one">1 member</item>
<item quantity="other">%d members</item>
</plurals>
<string name="ConversationActivity_saved_draft">Saved draft</string> <string name="ConversationActivity_saved_draft">Saved draft</string>
<string name="ConversationActivity_invalid_recipient">Invalid recipient!</string> <string name="ConversationActivity_invalid_recipient">Invalid recipient!</string>
<string name="ConversationActivity_calls_not_supported">Calls not supported</string> <string name="ConversationActivity_calls_not_supported">Calls not supported</string>

View File

@ -82,8 +82,7 @@ public class ConversationTitleView extends LinearLayout {
int size = recipients.getRecipientsList().size(); int size = recipients.getRecipientsList().size();
title.setText(getContext().getString(R.string.ConversationActivity_group_conversation)); title.setText(getContext().getString(R.string.ConversationActivity_group_conversation));
subtitle.setText((size == 1) ? getContext().getString(R.string.ConversationActivity_d_recipients_in_group_singular) : subtitle.setText(getContext().getResources().getQuantityString(R.plurals.ConversationActivity_d_recipients_in_group, size, size));
String.format(getContext().getString(R.string.ConversationActivity_d_recipients_in_group), size));
subtitle.setVisibility(View.VISIBLE); subtitle.setVisibility(View.VISIBLE);
} }

View File

@ -76,7 +76,7 @@ public class AppProtectionPreferenceFragment extends PreferenceFragment {
private void initializeTimeoutSummary() { private void initializeTimeoutSummary() {
int timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(getActivity()); int timeoutMinutes = TextSecurePreferences.getPassphraseTimeoutInterval(getActivity());
this.findPreference(TextSecurePreferences.PASSPHRASE_TIMEOUT_INTERVAL_PREF) this.findPreference(TextSecurePreferences.PASSPHRASE_TIMEOUT_INTERVAL_PREF)
.setSummary(getString(R.string.AppProtectionPreferenceFragment_minutes, timeoutMinutes)); .setSummary(getResources().getQuantityString(R.plurals.AppProtectionPreferenceFragment_minutes, timeoutMinutes, timeoutMinutes));
} }
private class BlockedContactsClickListener implements Preference.OnPreferenceClickListener { private class BlockedContactsClickListener implements Preference.OnPreferenceClickListener {

View File

@ -77,8 +77,8 @@ public class ChatsPreferenceFragment extends PreferenceFragment {
final int threadLengthLimit = TextSecurePreferences.getThreadTrimLength(getActivity()); final int threadLengthLimit = TextSecurePreferences.getThreadTrimLength(getActivity());
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(R.string.ApplicationPreferencesActivity_delete_all_old_messages_now); builder.setTitle(R.string.ApplicationPreferencesActivity_delete_all_old_messages_now);
builder.setMessage(getString(R.string.ApplicationPreferencesActivity_this_will_immediately_trim_all_conversations_to_the_s_most_recent_messages, builder.setMessage(getResources().getQuantityString(R.plurals.ApplicationPreferencesActivity_this_will_immediately_trim_all_conversations_to_the_d_most_recent_messages,
threadLengthLimit)); threadLengthLimit, threadLengthLimit));
builder.setPositiveButton(R.string.ApplicationPreferencesActivity_delete, builder.setPositiveButton(R.string.ApplicationPreferencesActivity_delete,
new DialogInterface.OnClickListener() { new DialogInterface.OnClickListener() {
@Override @Override
@ -107,7 +107,7 @@ public class ChatsPreferenceFragment extends PreferenceFragment {
public TrimLengthValidationListener() { public TrimLengthValidationListener() {
EditTextPreference preference = (EditTextPreference)findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH); EditTextPreference preference = (EditTextPreference)findPreference(TextSecurePreferences.THREAD_TRIM_LENGTH);
preference.setSummary(getString(R.string.ApplicationPreferencesActivity_messages_per_conversation, preference.getText())); onPreferenceChange(preference, preference.getText());
} }
@Override @Override
@ -116,18 +116,19 @@ public class ChatsPreferenceFragment extends PreferenceFragment {
return false; return false;
} }
int value;
try { try {
Integer.parseInt((String)newValue); value = Integer.parseInt((String)newValue);
} catch (NumberFormatException nfe) { } catch (NumberFormatException nfe) {
Log.w(TAG, nfe); Log.w(TAG, nfe);
return false; return false;
} }
if (Integer.parseInt((String)newValue) < 1) { if (value < 1) {
return false; return false;
} }
preference.setSummary(getString(R.string.ApplicationPreferencesActivity_messages_per_conversation, newValue)); preference.setSummary(getResources().getQuantityString(R.plurals.ApplicationPreferencesActivity_messages_per_conversation, value, value));
return true; return true;
} }
} }