Skip to content

Commit b06fa64

Browse files
committed
compose: Translate "(loading message {messageId})"
and implement the necessary plumbing to access ZulipLocalizations Signed-off-by: Zixuan James Li <[email protected]>
1 parent 587ef63 commit b06fa64

14 files changed

+68
-7
lines changed

assets/l10n/app_en.arb

+7
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,13 @@
351351
"filename": {"type": "String", "example": "file.txt"}
352352
}
353353
},
354+
"composeBoxLoadingMessage": "(loading message {messageId})",
355+
"@composeBoxLoadingMessage": {
356+
"description": "Placeholder in compose box showing the quoted message is currently loading.",
357+
"placeholders": {
358+
"messageId": {"type": "int", "example": "1234"}
359+
}
360+
},
354361
"unknownUserName": "(unknown user)",
355362
"@unknownUserName": {
356363
"description": "Name placeholder to use for a user when we don't know their name."

lib/generated/l10n/zulip_localizations.dart

+6
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,12 @@ abstract class ZulipLocalizations {
567567
/// **'Uploading {filename}…'**
568568
String composeBoxUploadingFilename(String filename);
569569

570+
/// Placeholder in compose box showing the quoted message is currently loading.
571+
///
572+
/// In en, this message translates to:
573+
/// **'(loading message {messageId})'**
574+
String composeBoxLoadingMessage(int messageId);
575+
570576
/// Name placeholder to use for a user when we don't know their name.
571577
///
572578
/// In en, this message translates to:

lib/generated/l10n/zulip_localizations_ar.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsAr extends ZulipLocalizations {
277277
return 'Uploading $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(unknown user)';
282287

lib/generated/l10n/zulip_localizations_en.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsEn extends ZulipLocalizations {
277277
return 'Uploading $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(unknown user)';
282287

lib/generated/l10n/zulip_localizations_ja.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsJa extends ZulipLocalizations {
277277
return 'Uploading $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(unknown user)';
282287

lib/generated/l10n/zulip_localizations_nb.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsNb extends ZulipLocalizations {
277277
return 'Uploading $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(unknown user)';
282287

lib/generated/l10n/zulip_localizations_pl.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsPl extends ZulipLocalizations {
277277
return 'Przekazywanie $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(nieznany użytkownik)';
282287

lib/generated/l10n/zulip_localizations_ru.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsRu extends ZulipLocalizations {
277277
return 'Загрузка $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(неизвестный пользователь)';
282287

lib/generated/l10n/zulip_localizations_sk.dart

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ class ZulipLocalizationsSk extends ZulipLocalizations {
277277
return 'Uploading $filename…';
278278
}
279279

280+
@override
281+
String composeBoxLoadingMessage(int messageId) {
282+
return '(loading message $messageId)';
283+
}
284+
280285
@override
281286
String get unknownUserName => '(unknown user)';
282287

lib/model/compose.dart

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:math';
22

33
import '../api/model/model.dart';
4+
import '../generated/l10n/zulip_localizations.dart';
45
import 'internal_link.dart';
56
import 'narrow.dart';
67
import 'store.dart';
@@ -182,7 +183,9 @@ String inlineLink(String visibleText, Uri? destination) {
182183
}
183184

184185
/// What we show while fetching the target message's raw Markdown.
185-
String quoteAndReplyPlaceholder(PerAccountStore store, {
186+
String quoteAndReplyPlaceholder(
187+
ZulipLocalizations zulipLocalizations,
188+
PerAccountStore store, {
186189
required Message message,
187190
}) {
188191
final sender = store.users[message.senderId];
@@ -192,7 +195,7 @@ String quoteAndReplyPlaceholder(PerAccountStore store, {
192195
nearMessageId: message.id);
193196
// See note in [quoteAndReply] about asking `mention` to omit the |<id> part.
194197
return '${userMention(sender!, silent: true)} ${inlineLink('said', url)}: ' // TODO(#1285)
195-
'*(loading message ${message.id})*\n'; // TODO(i18n) ?
198+
'*${zulipLocalizations.composeBoxLoadingMessage(message.id)}*\n';
196199
}
197200

198201
/// Quote-and-reply syntax.

lib/widgets/action_sheet.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,9 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
665665
// This inserts a "[Quoting…]" placeholder into the content input,
666666
// giving the user a form of progress feedback.
667667
final tag = composeBoxController.content
668-
.registerQuoteAndReplyStart(PerAccountStoreWidget.of(pageContext),
668+
.registerQuoteAndReplyStart(
669+
zulipLocalizations,
670+
PerAccountStoreWidget.of(pageContext),
669671
message: message,
670672
);
671673

lib/widgets/compose_box.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -266,10 +266,15 @@ class ComposeContentController extends ComposeController<ContentValidationError>
266266
///
267267
/// Returns an int "tag" that should be passed to registerQuoteAndReplyEnd on
268268
/// success or failure
269-
int registerQuoteAndReplyStart(PerAccountStore store, {required Message message}) {
269+
int registerQuoteAndReplyStart(
270+
ZulipLocalizations zulipLocalizations,
271+
PerAccountStore store, {
272+
required Message message,
273+
}) {
270274
final tag = _nextQuoteAndReplyTag;
271275
_nextQuoteAndReplyTag += 1;
272-
final placeholder = quoteAndReplyPlaceholder(store, message: message);
276+
final placeholder = quoteAndReplyPlaceholder(
277+
zulipLocalizations, store, message: message);
273278
_quoteAndReplies[tag] = (messageId: message.id, placeholder: placeholder);
274279
notifyListeners(); // _quoteAndReplies change could affect validationErrors
275280
insertPadded(placeholder);

test/model/compose_test.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:checks/checks.dart';
22
import 'package:test/scaffolding.dart';
33
import 'package:zulip/model/compose.dart';
4+
import 'package:zulip/model/localizations.dart';
45
import 'package:zulip/model/store.dart';
56

67
import '../example_data.dart' as eg;
@@ -288,7 +289,8 @@ hello
288289
await store.addStream(stream);
289290
await store.addUser(sender);
290291

291-
check(quoteAndReplyPlaceholder(store, message: message)).equals('''
292+
check(quoteAndReplyPlaceholder(
293+
GlobalLocalizations.zulipLocalizations, store, message: message)).equals('''
292294
@_**Full Name|123** [said](${eg.selfAccount.realmUrl}#narrow/stream/1-test-here/topic/some.20topic/near/${message.id}): *(loading message ${message.id})*
293295
''');
294296

test/widgets/action_sheet_test.dart

+2-1
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,8 @@ void main() {
641641
}) {
642642
check(contentController).value.equals((ComposeContentController()
643643
..value = valueBefore
644-
..insertPadded(quoteAndReplyPlaceholder(store, message: message))
644+
..insertPadded(quoteAndReplyPlaceholder(
645+
GlobalLocalizations.zulipLocalizations, store, message: message))
645646
).value);
646647
check(contentController).validationErrors.contains(ContentValidationError.quoteAndReplyInProgress);
647648
}

0 commit comments

Comments
 (0)