Skip to content

Commit d78d008

Browse files
committed
compose: Show maxTopicLength in the error message
1 parent 43caaae commit d78d008

10 files changed

+63
-17
lines changed

assets/l10n/app_en.arb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,9 +526,12 @@
526526
"@loginErrorMissingUsername": {
527527
"description": "Error message when an empty username was provided."
528528
},
529-
"topicValidationErrorTooLong": "Topic length shouldn't be greater than 60 characters.",
529+
"topicValidationErrorTooLong": "Topic length shouldn't be greater than {num, plural, =1{1 character} other{{num} characters}}.",
530530
"@topicValidationErrorTooLong": {
531-
"description": "Topic validation error when topic is too long."
531+
"description": "Topic validation error when topic is too long.",
532+
"placeholders": {
533+
"num": {"type": "int", "example": "60"}
534+
}
532535
},
533536
"topicValidationErrorMandatoryButEmpty": "Topics are required in this organization.",
534537
"@topicValidationErrorMandatoryButEmpty": {

lib/generated/l10n/zulip_localizations.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -810,8 +810,8 @@ abstract class ZulipLocalizations {
810810
/// Topic validation error when topic is too long.
811811
///
812812
/// In en, this message translates to:
813-
/// **'Topic length shouldn\'t be greater than 60 characters.'**
814-
String get topicValidationErrorTooLong;
813+
/// **'Topic length shouldn\'t be greater than {num, plural, =1{1 character} other{{num} characters}}.'**
814+
String topicValidationErrorTooLong(int num);
815815

816816
/// Topic validation error when topic is required but was empty.
817817
///

lib/generated/l10n/zulip_localizations_ar.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Please enter your username.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Topic length shouldn\'t be greater than 60 characters.';
411+
String topicValidationErrorTooLong(int num) {
412+
String _temp0 = intl.Intl.pluralLogic(
413+
num,
414+
locale: localeName,
415+
other: '$num characters',
416+
one: '1 character',
417+
);
418+
return 'Topic length shouldn\'t be greater than $_temp0.';
419+
}
412420

413421
@override
414422
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';

lib/generated/l10n/zulip_localizations_en.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Please enter your username.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Topic length shouldn\'t be greater than 60 characters.';
411+
String topicValidationErrorTooLong(int num) {
412+
String _temp0 = intl.Intl.pluralLogic(
413+
num,
414+
locale: localeName,
415+
other: '$num characters',
416+
one: '1 character',
417+
);
418+
return 'Topic length shouldn\'t be greater than $_temp0.';
419+
}
412420

413421
@override
414422
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';

lib/generated/l10n/zulip_localizations_ja.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Please enter your username.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Topic length shouldn\'t be greater than 60 characters.';
411+
String topicValidationErrorTooLong(int num) {
412+
String _temp0 = intl.Intl.pluralLogic(
413+
num,
414+
locale: localeName,
415+
other: '$num characters',
416+
one: '1 character',
417+
);
418+
return 'Topic length shouldn\'t be greater than $_temp0.';
419+
}
412420

413421
@override
414422
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';

lib/generated/l10n/zulip_localizations_nb.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Please enter your username.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Topic length shouldn\'t be greater than 60 characters.';
411+
String topicValidationErrorTooLong(int num) {
412+
String _temp0 = intl.Intl.pluralLogic(
413+
num,
414+
locale: localeName,
415+
other: '$num characters',
416+
one: '1 character',
417+
);
418+
return 'Topic length shouldn\'t be greater than $_temp0.';
419+
}
412420

413421
@override
414422
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';

lib/generated/l10n/zulip_localizations_pl.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Proszę podaj nazwę użytkownika.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Tytuł nie może być dłuższy niż 60 znaków.';
411+
String topicValidationErrorTooLong(int num) {
412+
return 'Tytuł nie może być dłuższy niż 60 znaków.';
413+
}
412414

413415
@override
414416
String get topicValidationErrorMandatoryButEmpty => 'Wątki są wymagane przez tę organizację.';

lib/generated/l10n/zulip_localizations_ru.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Пожалуйста, введите ваше имя пользователя.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Длина темы не должна превышать 60 символов.';
411+
String topicValidationErrorTooLong(int num) {
412+
return 'Длина темы не должна превышать 60 символов.';
413+
}
412414

413415
@override
414416
String get topicValidationErrorMandatoryButEmpty => 'Темы обязательны в этой организации.';

lib/generated/l10n/zulip_localizations_sk.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,15 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
408408
String get loginErrorMissingUsername => 'Prosím zadajte prihlasovacie meno.';
409409

410410
@override
411-
String get topicValidationErrorTooLong => 'Topic length shouldn\'t be greater than 60 characters.';
411+
String topicValidationErrorTooLong(int num) {
412+
String _temp0 = intl.Intl.pluralLogic(
413+
num,
414+
locale: localeName,
415+
other: '$num characters',
416+
one: '1 character',
417+
);
418+
return 'Topic length shouldn\'t be greater than $_temp0.';
419+
}
412420

413421
@override
414422
String get topicValidationErrorMandatoryButEmpty => 'Topics are required in this organization.';

lib/widgets/compose_box.dart

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ enum TopicValidationError {
131131
mandatoryButEmpty,
132132
tooLong;
133133

134-
String message(ZulipLocalizations zulipLocalizations) {
134+
String message(ZulipLocalizations zulipLocalizations, {required int maxTopicLength}) {
135135
switch (this) {
136136
case tooLong:
137-
return zulipLocalizations.topicValidationErrorTooLong;
137+
return zulipLocalizations.topicValidationErrorTooLong(maxTopicLength);
138138
case mandatoryButEmpty:
139139
return zulipLocalizations.topicValidationErrorMandatoryButEmpty;
140140
}
@@ -1105,10 +1105,9 @@ class _SendButtonState extends State<_SendButton> {
11051105
if (_hasValidationErrors) {
11061106
final zulipLocalizations = ZulipLocalizations.of(context);
11071107
List<String> validationErrorMessages = [
1108-
for (final error in (controller is StreamComposeBoxController
1109-
? controller.topic.validationErrors
1110-
: const <TopicValidationError>[]))
1111-
error.message(zulipLocalizations),
1108+
if (controller is StreamComposeBoxController)
1109+
for (final error in controller.topic.validationErrors)
1110+
error.message(zulipLocalizations, maxTopicLength: controller.topic.maxLengthUnicodeCodePoints),
11121111
for (final error in controller.content.validationErrors)
11131112
error.message(zulipLocalizations),
11141113
];

0 commit comments

Comments
 (0)