Skip to content

Commit a78f66c

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 3eb36ac commit a78f66c

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';
@@ -136,7 +137,9 @@ String inlineLink(String visibleText, Uri? destination) {
136137
}
137138

138139
/// What we show while fetching the target message's raw Markdown.
139-
String quoteAndReplyPlaceholder(PerAccountStore store, {
140+
String quoteAndReplyPlaceholder(
141+
ZulipLocalizations zulipLocalizations,
142+
PerAccountStore store, {
140143
required Message message,
141144
}) {
142145
final sender = store.users[message.senderId];
@@ -146,7 +149,7 @@ String quoteAndReplyPlaceholder(PerAccountStore store, {
146149
nearMessageId: message.id);
147150
// See note in [quoteAndReply] about asking `mention` to omit the |<id> part.
148151
return '${mention(sender!, silent: true)} ${inlineLink('said', url)}: ' // TODO(#1285)
149-
'*(loading message ${message.id})*\n'; // TODO(i18n) ?
152+
'*${zulipLocalizations.composeBoxLoadingMessage(message.id)}*\n';
150153
}
151154

152155
/// 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
@@ -213,10 +213,15 @@ class ComposeContentController extends ComposeController<ContentValidationError>
213213
///
214214
/// Returns an int "tag" that should be passed to registerQuoteAndReplyEnd on
215215
/// success or failure
216-
int registerQuoteAndReplyStart(PerAccountStore store, {required Message message}) {
216+
int registerQuoteAndReplyStart(
217+
ZulipLocalizations zulipLocalizations,
218+
PerAccountStore store, {
219+
required Message message,
220+
}) {
217221
final tag = _nextQuoteAndReplyTag;
218222
_nextQuoteAndReplyTag += 1;
219-
final placeholder = quoteAndReplyPlaceholder(store, message: message);
223+
final placeholder = quoteAndReplyPlaceholder(
224+
zulipLocalizations, store, message: message);
220225
_quoteAndReplies[tag] = (messageId: message.id, placeholder: placeholder);
221226
notifyListeners(); // _quoteAndReplies change could affect validationErrors
222227
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

56
import '../example_data.dart' as eg;
67
import 'test_store.dart';
@@ -260,7 +261,8 @@ hello
260261
await store.addStream(stream);
261262
await store.addUser(sender);
262263

263-
check(quoteAndReplyPlaceholder(store, message: message)).equals('''
264+
check(quoteAndReplyPlaceholder(
265+
GlobalLocalizations.zulipLocalizations, store, message: message)).equals('''
264266
@_**Full Name|123** [said](${eg.selfAccount.realmUrl}#narrow/stream/1-test-here/topic/some.20topic/near/${message.id}): *(loading message ${message.id})*
265267
''');
266268

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)