Rewrite more plural handling of 'Hours'

This commit is contained in:
Dr. Tobias Quathamer
2017-02-09 09:48:22 +01:00
parent 82382f31f1
commit 5f00826e65
6 changed files with 18 additions and 12 deletions
@@ -1529,9 +1529,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); // was: BottomSheet.Builder
//builder.setTitle(LocaleController.getString("Notifications", R.string.Notifications)); -- a title seems more confusing than helping -- the user has clicked "mute" before and there are several options all starting with "mute...", I think, this is very clear
CharSequence[] items = new CharSequence[]{
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 1)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Hours", 8)),
LocaleController.formatString("MuteFor", R.string.MuteFor, LocaleController.formatPluralString("Days", 2)),
ApplicationLoader.applicationContext.getString(R.string.MuteFor1Hour),
ApplicationLoader.applicationContext.getString(R.string.MuteFor8Hours),
ApplicationLoader.applicationContext.getString(R.string.MuteFor2Days),
LocaleController.getString("MuteAlways", R.string.MuteAlways)
};
builder.setItems(items, new DialogInterface.OnClickListener() {
@@ -437,9 +437,9 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 5, 5),
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 10, 10),
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 30, 30),
LocaleController.formatPluralString("Hours", 1),
LocaleController.formatPluralString("Hours", 2),
LocaleController.formatPluralString("Hours", 4)
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, 1, 1),
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, 2, 2),
ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, 4, 4)
}, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
@@ -681,7 +681,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif
} else if (minutes < 60) {
value = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, minutes, minutes);
} else {
value = LocaleController.formatPluralString("Hours", minutes / 60);
value = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, minutes / 60, minutes / 60);
}
textCell.setTextAndValue(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications), value, true);
}
@@ -375,9 +375,9 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} else if (value == 2) {
return ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, 5, 5);
} else if (value == 3) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 1));
return ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, 1, 1);
} else if (value == 4) {
return LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", 5));
return ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, 5, 5);
}
return "";
}
@@ -676,7 +676,7 @@ public class PasscodeActivity extends BaseFragment implements NotificationCenter
} else if (UserConfig.autoLockIn < 60 * 60) {
val = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Minutes, UserConfig.autoLockIn / 60, UserConfig.autoLockIn / 60);
} else if (UserConfig.autoLockIn < 60 * 60 * 24) {
val = LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Hours", (int) Math.ceil(UserConfig.autoLockIn / 60.0f / 60)));
val = ApplicationLoader.applicationContext.getResources().getQuantityString(R.plurals.Hours, (int) Math.ceil(UserConfig.autoLockIn / 60.0f / 60), (int) Math.ceil(UserConfig.autoLockIn / 60.0f / 60));
} else {
val = LocaleController.formatString("AutoLockInTime", R.string.AutoLockInTime, LocaleController.formatPluralString("Days", (int) Math.ceil(UserConfig.autoLockIn / 60.0f / 60 / 24)));
}
@@ -586,7 +586,8 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi
// @TODO: Maybe this should be reworded a bit.
val = mContext.getResources().getQuantityString(R.plurals.Minutes, delta / 60, delta / 60);
} else if (delta < 60 * 60 * 24) {
val = LocaleController.formatString("WillUnmuteIn", R.string.WillUnmuteIn, LocaleController.formatPluralString("Hours", (int) Math.ceil(delta / 60.0f / 60)));
// @TODO: Maybe this should be reworded a bit.
val = mContext.getResources().getQuantityString(R.plurals.Hours, (int) Math.ceil(delta / 60.0f / 60), (int) Math.ceil(delta / 60.0f / 60));
} else if (delta < 60 * 60 * 24 * 365) {
val = LocaleController.formatString("WillUnmuteIn", R.string.WillUnmuteIn, LocaleController.formatPluralString("Days", (int) Math.ceil(delta / 60.0f / 60 / 24)));
} else {
@@ -20,6 +20,9 @@
<string name="SelectChat">Chat auswählen …</string>
<string name="Search">Suche</string>
<string name="MuteNotifications">Stummschalten</string>
<string name="MuteFor1Hour">Stumm für 1 Stunde</string>
<string name="MuteFor8Hours">Stumm für 8 Stunden</string>
<string name="MuteFor2Days">Stumm für 2 Tage</string>
<string name="MuteFor">Stumm für %1$s</string>
<string name="UnmuteNotifications">Stumm aus</string>
<string name="WillUnmuteIn">In %1$s</string>
@@ -20,7 +20,9 @@
<string name="SelectChat">Select chat …</string>
<string name="Search">Search</string>
<string name="MuteNotifications">Mute notifications</string>
<string name="MuteFor">Mute for %1$s</string>
<string name="MuteFor1Hour">Mute for 1 hour</string>
<string name="MuteFor8Hours">Mute for 8 hours</string>
<string name="MuteFor2Days">Mute for 2 days</string>
<string name="UnmuteNotifications">Unmute</string>
<string name="WillUnmuteIn">In %1$s</string>
<string name="Draft">Draft</string>