Skip to content

Commit da9daa0

Browse files
committed
compose: Add translations to UI widgets
1 parent fcf39fa commit da9daa0

File tree

2 files changed

+79
-15
lines changed

2 files changed

+79
-15
lines changed

assets/l10n/app_en.arb

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,57 @@
132132
"@successMessageCopied": {
133133
"description": "Message when content of a message was copied to the users system clipboard."
134134
},
135+
"composeBoxAttachFilesTooltip": "Attach files",
136+
"@composeBoxAttachFilesTooltip": {
137+
"description": "Tooltip for compose box icon to attach a file to the message."
138+
},
139+
"composeBoxAttachMediaTooltip": "Attach images or videos",
140+
"@composeBoxAttachMediaTooltip": {
141+
"description": "Tooltip for compose box icon to attach media to the message."
142+
},
143+
"composeBoxAttachFromCameraTooltip": "Take a photo",
144+
"@composeBoxAttachFromCameraTooltip": {
145+
"description": "Tooltip for compose box icon to attach an image from the camera to the message."
146+
},
147+
"composeBoxGenericContentHint": "Type a message",
148+
"@composeBoxGenericContentHint": {
149+
"description": "Hint text for content input when sending a message."
150+
},
151+
"composeBoxDmContentHint": "Message @{user}",
152+
"@composeBoxDmContentHint": {
153+
"description": "Hint text for content input when sending a message to one other person.",
154+
"placeholders": {
155+
"user": {"type": "String", "example": "stream name"}
156+
}
157+
},
158+
"composeBoxGroupDmContentHint": "Message group",
159+
"@composeBoxGroupDmContentHint": {
160+
"description": "Hint text for content input when sending a message to a group."
161+
},
162+
"composeBoxSelfDmContentHint": "Jot down something",
163+
"@composeBoxSelfDmContentHint": {
164+
"description": "Hint text for content input when sending a message to yourself."
165+
},
166+
"composeBoxStreamContentHint": "Message #{stream} > {topic}",
167+
"@composeBoxStreamContentHint": {
168+
"description": "Hint text for content input when sending a message to a stream",
169+
"placeholders": {
170+
"stream": {"type": "String", "example": "stream name"},
171+
"topic": {"type": "String", "example": "topic name"}
172+
}
173+
},
174+
"composeBoxSendTooltip": "Send",
175+
"@composeBoxSendTooltip": {
176+
"description": "Tooltip for send button in compose box."
177+
},
178+
"composeBoxUnknownStreamName": "(unknown stream)",
179+
"@composeBoxUnknownStreamName": {
180+
"description": "Replacement name for stream when it cannot be found in the store."
181+
},
182+
"composeBoxTopicHintText": "Topic",
183+
"@composeBoxTopicHintText": {
184+
"description": "Hint text for topic input widget in compose box."
185+
},
135186
"composeBoxUploadingFilename": "Uploading {filename}...",
136187
"@composeBoxUploadingFilename": {
137188
"description": "Label in compose box showing the specified file is currently uploading.",

lib/widgets/compose_box.dart

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,14 @@ class _StreamContentInputState extends State<_StreamContentInput> {
360360
@override
361361
Widget build(BuildContext context) {
362362
final store = PerAccountStoreWidget.of(context);
363-
final streamName = store.streams[widget.narrow.streamId]?.name ?? '(unknown stream)';
363+
final zulipLocalizations = ZulipLocalizations.of(context);
364+
final streamName = store.streams[widget.narrow.streamId]?.name
365+
?? zulipLocalizations.composeBoxUnknownStreamName;
364366
return _ContentInput(
365367
narrow: widget.narrow,
366368
controller: widget.controller,
367369
focusNode: widget.focusNode,
368-
hintText: "Message #$streamName > $_topicTextNormalized");
370+
hintText: zulipLocalizations.composeBoxStreamContentHint(streamName, _topicTextNormalized));
369371
}
370372
}
371373

@@ -381,23 +383,25 @@ class _FixedDestinationContentInput extends StatelessWidget {
381383
final FocusNode focusNode;
382384

383385
String _hintText(BuildContext context) {
386+
final zulipLocalizations = ZulipLocalizations.of(context);
384387
switch (narrow) {
385388
case TopicNarrow(:final streamId, :final topic):
386389
final store = PerAccountStoreWidget.of(context);
387-
final streamName = store.streams[streamId]?.name ?? '(unknown stream)';
388-
return "Message #$streamName > $topic";
390+
final streamName = store.streams[streamId]?.name
391+
?? zulipLocalizations.composeBoxUnknownStreamName;
392+
return zulipLocalizations.composeBoxStreamContentHint(streamName, topic);
389393

390394
case DmNarrow(otherRecipientIds: []): // The self-1:1 thread.
391-
return "Jot down something";
395+
return zulipLocalizations.composeBoxSelfDmContentHint;
392396

393397
case DmNarrow(otherRecipientIds: [final otherUserId]):
394398
final store = PerAccountStoreWidget.of(context);
395399
final fullName = store.users[otherUserId]?.fullName;
396-
if (fullName == null) return 'Type a message';
397-
return 'Message @$fullName';
400+
if (fullName == null) return zulipLocalizations.composeBoxGenericContentHint;
401+
return zulipLocalizations.composeBoxDmContentHint(fullName);
398402

399403
case DmNarrow(): // A group DM thread.
400-
return 'Message group';
404+
return zulipLocalizations.composeBoxGroupDmContentHint;
401405
}
402406
}
403407

@@ -493,7 +497,7 @@ abstract class _AttachUploadsButton extends StatelessWidget {
493497
final FocusNode contentFocusNode;
494498

495499
IconData get icon;
496-
String get tooltip;
500+
String tooltip(ZulipLocalizations zulipLocalizations);
497501

498502
/// Request files from the user, in the way specific to this upload type.
499503
///
@@ -525,9 +529,10 @@ abstract class _AttachUploadsButton extends StatelessWidget {
525529

526530
@override
527531
Widget build(BuildContext context) {
532+
final zulipLocalizations = ZulipLocalizations.of(context);
528533
return IconButton(
529534
icon: Icon(icon),
530-
tooltip: tooltip,
535+
tooltip: tooltip(zulipLocalizations),
531536
onPressed: () => _handlePress(context));
532537
}
533538
}
@@ -576,8 +581,10 @@ class _AttachFileButton extends _AttachUploadsButton {
576581

577582
@override
578583
IconData get icon => Icons.attach_file;
584+
579585
@override
580-
String get tooltip => 'Attach files';
586+
String tooltip(ZulipLocalizations zulipLocalizations) =>
587+
zulipLocalizations.composeBoxAttachFilesTooltip;
581588

582589
@override
583590
Future<Iterable<_File>> getFiles(BuildContext context) async {
@@ -590,8 +597,10 @@ class _AttachMediaButton extends _AttachUploadsButton {
590597

591598
@override
592599
IconData get icon => Icons.image;
600+
593601
@override
594-
String get tooltip => 'Attach images or videos';
602+
String tooltip(ZulipLocalizations zulipLocalizations) =>
603+
zulipLocalizations.composeBoxAttachMediaTooltip;
595604

596605
@override
597606
Future<Iterable<_File>> getFiles(BuildContext context) async {
@@ -605,8 +614,10 @@ class _AttachFromCameraButton extends _AttachUploadsButton {
605614

606615
@override
607616
IconData get icon => Icons.camera_alt;
617+
608618
@override
609-
String get tooltip => 'Take a photo';
619+
String tooltip(ZulipLocalizations zulipLocalizations) =>
620+
zulipLocalizations.composeBoxAttachFromCameraTooltip;
610621

611622
@override
612623
Future<Iterable<_File>> getFiles(BuildContext context) async {
@@ -731,6 +742,7 @@ class _SendButtonState extends State<_SendButton> {
731742
Widget build(BuildContext context) {
732743
final disabled = _hasValidationErrors;
733744
final colorScheme = Theme.of(context).colorScheme;
745+
final zulipLocalizations = ZulipLocalizations.of(context);
734746

735747
// Copy FilledButton defaults (_FilledButtonDefaultsM3.backgroundColor)
736748
final backgroundColor = disabled
@@ -748,7 +760,7 @@ class _SendButtonState extends State<_SendButton> {
748760
color: backgroundColor,
749761
),
750762
child: IconButton(
751-
tooltip: 'Send',
763+
tooltip: zulipLocalizations.composeBoxSendTooltip,
752764

753765
// Match the height of the content input. Zeroing the padding lets the
754766
// constraints take over.
@@ -866,14 +878,15 @@ class _StreamComposeBoxState extends State<_StreamComposeBox> implements Compose
866878
@override
867879
Widget build(BuildContext context) {
868880
final colorScheme = Theme.of(context).colorScheme;
881+
final zulipLocalizations = ZulipLocalizations.of(context);
869882

870883
return _ComposeBoxLayout(
871884
contentController: _contentController,
872885
contentFocusNode: _contentFocusNode,
873886
topicInput: TextField(
874887
controller: _topicController,
875888
style: TextStyle(color: colorScheme.onSurface),
876-
decoration: const InputDecoration(hintText: 'Topic'),
889+
decoration: InputDecoration(hintText: zulipLocalizations.composeBoxTopicHintText),
877890
),
878891
contentInput: _StreamContentInput(
879892
narrow: widget.narrow,

0 commit comments

Comments
 (0)