Skip to content

Commit 0227c84

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 7691f86 commit 0227c84

14 files changed

+69
-7
lines changed

assets/l10n/app_en.arb

Lines changed: 7 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 0 deletions
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,9 @@ class QuoteAndReplyButton extends MessageActionSheetMenuItemButton {
650650
// This inserts a "[Quoting…]" placeholder into the content input,
651651
// giving the user a form of progress feedback.
652652
final tag = composeBoxController.content
653-
.registerQuoteAndReplyStart(PerAccountStoreWidget.of(pageContext),
653+
.registerQuoteAndReplyStart(
654+
zulipLocalizations,
655+
PerAccountStoreWidget.of(pageContext),
654656
message: message,
655657
);
656658

lib/widgets/compose_box.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,15 @@ class ComposeContentController extends ComposeController<ContentValidationError>
175175
///
176176
/// Returns an int "tag" that should be passed to registerQuoteAndReplyEnd on
177177
/// success or failure
178-
int registerQuoteAndReplyStart(PerAccountStore store, {required Message message}) {
178+
int registerQuoteAndReplyStart(
179+
ZulipLocalizations zulipLocalizations,
180+
PerAccountStore store, {
181+
required Message message,
182+
}) {
179183
final tag = _nextQuoteAndReplyTag;
180184
_nextQuoteAndReplyTag += 1;
181-
final placeholder = quoteAndReplyPlaceholder(store, message: message);
185+
final placeholder = quoteAndReplyPlaceholder(
186+
zulipLocalizations, store, message: message);
182187
_quoteAndReplies[tag] = (messageId: message.id, placeholder: placeholder);
183188
notifyListeners(); // _quoteAndReplies change could affect validationErrors
184189
insertPadded(placeholder);

test/model/compose_test.dart

Lines changed: 3 additions & 1 deletion
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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,9 @@ void main() {
574574
}) {
575575
check(contentController).value.equals((ComposeContentController()
576576
..value = valueBefore
577-
..insertPadded(quoteAndReplyPlaceholder(store, message: message))
577+
..insertPadded(
578+
quoteAndReplyPlaceholder(
579+
GlobalLocalizations.zulipLocalizations, store, message: message))
578580
).value);
579581
check(contentController).validationErrors.contains(ContentValidationError.quoteAndReplyInProgress);
580582
}

0 commit comments

Comments
 (0)