chore: add remaining translations

Signed-off-by: xsahil03x <[email protected]>
This commit is contained in:
Sahil Kumar
2021-07-19 16:51:49 +05:30
committed by xsahil03x
parent face836383
commit 67a36d9c35
12 changed files with 65 additions and 58 deletions
@@ -5,32 +5,6 @@ import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart'; import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:stream_chat_localizations/stream_chat_localizations.dart'; import 'package:stream_chat_localizations/stream_chat_localizations.dart';
/// A custom set of localizations for the 'hi' locale.
class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations {
const StreamChatLocalizationsHi() : super(localeName: 'hi');
static const LocalizationsDelegate<StreamChatLocalizations> delegate =
_HindiStreamChatLocalizationsDelegate();
@override
String get launchUrlError => 'URL लॉन्च नहीं कर सकता';
}
class _HindiStreamChatLocalizationsDelegate
extends LocalizationsDelegate<StreamChatLocalizations> {
const _HindiStreamChatLocalizationsDelegate();
@override
bool isSupported(Locale locale) => locale.languageCode == 'hi';
@override
Future<StreamChatLocalizations> load(Locale locale) =>
SynchronousFuture(const StreamChatLocalizationsHi());
@override
bool shouldReload(_HindiStreamChatLocalizationsDelegate old) => false;
}
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
@@ -96,18 +70,12 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) => MaterialApp( Widget build(BuildContext context) => MaterialApp(
theme: ThemeData.light(), theme: ThemeData.light(),
darkTheme: ThemeData.dark(), darkTheme: ThemeData.dark(),
themeMode: ThemeMode.system, localizationsDelegates: const [
supportedLocales: [ GlobalStreamChatLocalizations.delegate,
Locale('en', 'US'), GlobalCupertinoLocalizations.delegate,
Locale('hi', 'IN'), GlobalMaterialLocalizations.delegate,
], GlobalWidgetsLocalizations.delegate,
localizationsDelegates: [ ],
GlobalStreamChatLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
StreamChatLocalizationsHi.delegate,
],
builder: (context, widget) => StreamChat( builder: (context, widget) => StreamChat(
client: client, client: client,
child: widget, child: widget,
@@ -76,7 +76,7 @@ class FileAttachment extends AttachmentWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
attachment.title ?? 'File', attachment.title ?? context.translations.fileText,
style: StreamChatTheme.of(context).textTheme.bodyBold, style: StreamChatTheme.of(context).textTheme.bodyBold,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: TextOverflow.ellipsis,
@@ -200,7 +200,7 @@ class _FullScreenMediaState extends State<FullScreenMedia>
); );
}, },
), ),
if (widget.message.type != 'ephemeral') if (!widget.message.isEphemeral)
GalleryFooter( GalleryFooter(
currentPage: _currentPage, currentPage: _currentPage,
totalPages: widget.mediaAttachments.length, totalPages: widget.mediaAttachments.length,
@@ -136,7 +136,9 @@ class _GalleryFooterState extends State<GalleryFooter> {
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
Text( Text(
'${widget.currentPage + 1} of ${widget.totalPages}', '${widget.currentPage + 1} '
'${context.translations.ofText} '
'${widget.totalPages}',
style: galleryFooterThemeData.titleTextStyle, style: galleryFooterThemeData.titleTextStyle,
), ),
], ],
@@ -67,7 +67,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
: const SizedBox(), : const SizedBox(),
backgroundColor: galleryHeaderThemeData.backgroundColor, backgroundColor: galleryHeaderThemeData.backgroundColor,
actions: <Widget>[ actions: <Widget>[
if (message.type != 'ephemeral') if (!message.isEphemeral)
IconButton( IconButton(
icon: StreamSvgIcon.iconMenuPoint( icon: StreamSvgIcon.iconMenuPoint(
color: galleryHeaderThemeData.iconMenuPointColor, color: galleryHeaderThemeData.iconMenuPointColor,
@@ -78,7 +78,7 @@ class GalleryHeader extends StatelessWidget implements PreferredSizeWidget {
), ),
], ],
centerTitle: true, centerTitle: true,
title: message.type != 'ephemeral' title: !message.isEphemeral
? InkWell( ? InkWell(
onTap: onTitleTap, onTap: onTitleTap,
child: SizedBox( child: SizedBox(
@@ -190,6 +190,16 @@ abstract class Translations {
String get shuffleLabel; String get shuffleLabel;
String get sendLabel; String get sendLabel;
String get withText;
String get inText;
String get youText;
String get ofText;
String get fileText;
} }
class DefaultTranslations implements Translations { class DefaultTranslations implements Translations {
@@ -514,4 +524,19 @@ class DefaultTranslations implements Translations {
@override @override
String get sendLabel => 'Send'; String get sendLabel => 'Send';
@override
String get withText => 'with';
@override
String get inText => 'in';
@override
String get youText => 'You';
@override
String get ofText => 'of';
@override
String get fileText => 'File';
} }
@@ -2254,10 +2254,10 @@ class _PickerWidget extends StatefulWidget {
final StreamChatThemeData streamChatTheme; final StreamChatThemeData streamChatTheme;
@override @override
__PickerWidgetState createState() => __PickerWidgetState(); _PickerWidgetState createState() => _PickerWidgetState();
} }
class __PickerWidgetState extends State<_PickerWidget> { class _PickerWidgetState extends State<_PickerWidget> {
Future<bool>? requestPermission; Future<bool>? requestPermission;
@override @override
@@ -50,12 +50,14 @@ class MessageSearchItem extends StatelessWidget {
title: Row( title: Row(
children: [ children: [
Text( Text(
user.id == StreamChat.of(context).user?.id ? 'You' : user.name, user.id == StreamChat.of(context).user?.id
? context.translations.youText
: user.name,
style: chatThemeData.channelPreviewTheme.title, style: chatThemeData.channelPreviewTheme.title,
), ),
if (channelName != null) ...[ if (channelName != null) ...[
Text( Text(
' in ', ' ${context.translations.inText} ',
style: chatThemeData.channelPreviewTheme.title?.copyWith( style: chatThemeData.channelPreviewTheme.title?.copyWith(
fontWeight: FontWeight.normal, fontWeight: FontWeight.normal,
), ),
@@ -43,15 +43,10 @@ class MessageText extends StatelessWidget {
final mentionedUser = message.mentionedUsers.firstWhereOrNull( final mentionedUser = message.mentionedUsers.firstWhereOrNull(
(u) => '@${u.name}' == link, (u) => '@${u.name}' == link,
); );
if (mentionedUser == null) {
return;
}
if (onMentionTap != null) { if (mentionedUser == null) return;
onMentionTap!(mentionedUser);
} else { onMentionTap?.call(mentionedUser);
print('tap on ${mentionedUser.name}');
}
} else { } else {
if (onLinkTap != null) { if (onLinkTap != null) {
onLinkTap!(link); onLinkTap!(link);
@@ -13,8 +13,8 @@ class SystemMessage extends StatelessWidget {
/// This message /// This message
final Message message; final Message message;
// ignore: lines_longer_than_80_chars /// The function called when tapping on the message
/// The function called when tapping on the message when the message is not failed /// when the message is not failed
final void Function(Message)? onMessageTap; final void Function(Message)? onMessageTap;
@override @override
@@ -112,7 +112,7 @@ class ThreadHeader extends StatelessWidget implements PreferredSizeWidget {
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Text( Text(
'with ', '${context.translations.withText} ',
style: chatThemeData.channelTheme.channelHeaderTheme.subtitle, style: chatThemeData.channelTheme.channelHeaderTheme.subtitle,
), ),
Flexible( Flexible(
@@ -323,4 +323,19 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations {
@override @override
String get sendLabel => 'Send'; String get sendLabel => 'Send';
@override
String get withText => 'with';
@override
String get inText => 'in';
@override
String get youText => 'You';
@override
String get ofText => 'of';
@override
String get fileText => 'File';
} }