Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: localize raid events #1266

Merged
merged 7 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions lib/components/chat_history/twitch/raid_event.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:rtchat/components/chat_history/decorated_event.dart';
import 'package:rtchat/components/image/resilient_network_image.dart';
Expand All @@ -13,9 +13,7 @@ class TwitchRaidEventWidget extends StatelessWidget {
final TwitchRaidEventModel model;
final Channel channel;

final NumberFormat _formatter = NumberFormat.decimalPattern();

TwitchRaidEventWidget(this.model, {super.key, required this.channel});
const TwitchRaidEventWidget(this.model, {super.key, required this.channel});

@override
Widget build(BuildContext context) {
Expand All @@ -24,7 +22,8 @@ class TwitchRaidEventWidget extends StatelessWidget {
child: Row(children: [
Expanded(
child: StyledText(
text: '<b>${model.from.displayName}</b> is raiding with a party of ${_formatter.format(model.viewers)}',
text: AppLocalizations.of(context)!
.raidEventMessage(model.from.displayName ?? "", model.viewers),
tags: {
'b': StyledTextTag(style: Theme.of(context).textTheme.titleSmall),
},
Expand All @@ -38,7 +37,7 @@ class TwitchRaidEventWidget extends StatelessWidget {
}
return GestureDetector(
child: Text.rich(TextSpan(
text: "Shoutout",
text: AppLocalizations.of(context)!.shoutout,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
color:
Theme.of(context).buttonTheme.colorScheme?.primary))),
Expand Down
25 changes: 17 additions & 8 deletions lib/components/chat_history/twitch/raiding_event.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:provider/provider.dart';
import 'package:rtchat/components/chat_history/decorated_event.dart';
import 'package:rtchat/components/image/resilient_network_image.dart';
Expand Down Expand Up @@ -36,16 +37,21 @@ class TwitchRaidingEventWidget extends StatelessWidget {
child: Row(children: [
Expanded(
child: StyledText(
text: '<b>Raiding</b> ${model.targetUser.displayName}.',
text: AppLocalizations.of(context)!.raidingEventRaiding(
model.targetUser.displayName ?? ''),
tags: {
'b': StyledTextTag(style: Theme.of(context).textTheme.titleSmall),
'b': StyledTextTag(
style: Theme.of(context).textTheme.titleSmall),
},
),
),
Text.rich(TextSpan(
text: remaining.isNegative
? "0s"
: "${remaining.inSeconds + 1}s",
? AppLocalizations.of(context)!
.raidingEventTimeRemaining(0)
: AppLocalizations.of(context)!
.raidingEventTimeRemaining(
remaining.inSeconds + 1),
style: Theme.of(context).textTheme.titleSmall))
])),
]);
Expand All @@ -57,14 +63,16 @@ class TwitchRaidingEventWidget extends StatelessWidget {
child: Row(children: [
Expanded(
child: StyledText(
text: '<b>Raided</b> ${model.targetUser.displayName}.',
text: AppLocalizations.of(context)!
.raidingEventRaided(model.targetUser.displayName ?? ''),
tags: {
'b': StyledTextTag(style: Theme.of(context).textTheme.titleSmall),
'b': StyledTextTag(
style: Theme.of(context).textTheme.titleSmall),
},
),
),
Text.rich(TextSpan(
text: "Join",
text: AppLocalizations.of(context)!.raidingEventJoin,
style: Theme.of(context).textTheme.titleSmall?.copyWith(
color: Theme.of(context)
.buttonTheme
Expand All @@ -79,7 +87,8 @@ class TwitchRaidingEventWidget extends StatelessWidget {
return DecoratedEventWidget.avatar(
avatar: ResilientNetworkImage(model.targetUser.profilePictureUrl),
child: StyledText(
text: '<b>Raid to</b> ${model.targetUser.displayName} canceled.',
text: AppLocalizations.of(context)!
.raidingEventCanceled(model.targetUser.displayName ?? ''),
tags: {
'b': StyledTextTag(style: Theme.of(context).textTheme.titleSmall),
},
Expand Down
62 changes: 62 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -662,5 +662,67 @@
"customizeYourOutgoingRaidEvent": "Customize your outgoing raid event",
"@customizeYourOutgoingRaidEvent": {
"description": "Subtitle for the outgoing raid event configuration"
},
"raidEventMessage": "<bold>{displayName}</bold> is raiding with <bold>{viewerCount}</bold> viewers!",
"@raidEventMessage": {
"description": "Message displayed when a raid event occurs",
"placeholders": {
"displayName": {
"type": "String",
"example": "muxfd"
},
"viewerCount": {
"type": "int",
"format": "decimalPattern"
}
}
},
"shoutout": "Shoutout",
"@shoutout": {
"description": "Button text for the shoutout action in a raid event"
},
"raidingEventRaiding": "<bold>{displayName}</bold> is raiding...",
"@raidingEventRaiding": {
"description": "Message displayed when a raiding event is in progress",
"placeholders": {
"displayName": {
"type": "String",
"example": "muxfd"
}
}
},
"raidingEventTimeRemaining": "Time remaining: {seconds}s",
"@raidingEventTimeRemaining": {
"description": "Message displaying the time remaining for a raiding event",
"placeholders": {
"seconds": {
"type": "int",
"format": "decimalPattern"
}
}
},
"raidingEventRaided": "<bold>{displayName}</bold> has raided!",
"@raidingEventRaided": {
"description": "Message displayed when a raiding event has completed successfully",
"placeholders": {
"displayName": {
"type": "String",
"example": "muxfd"
}
}
},
"raidingEventJoin": "Join",
"@raidingEventJoin": {
"description": "Button text to join the raid in a raiding event"
},
"raidingEventCanceled": "<bold>{displayName}</bold>'s raid was canceled.",
"@raidingEventCanceled": {
"description": "Message displayed when a raiding event is canceled",
"placeholders": {
"displayName": {
"type": "String",
"example": "muxfd"
}
}
}
}
Loading