diff --git a/packages/stream_chat_flutter/example/lib/main.dart b/packages/stream_chat_flutter/example/lib/main.dart index f7609f6b..b340ac28 100644 --- a/packages/stream_chat_flutter/example/lib/main.dart +++ b/packages/stream_chat_flutter/example/lib/main.dart @@ -70,7 +70,12 @@ class MyApp extends StatelessWidget { Widget build(BuildContext context) => MaterialApp( theme: ThemeData.light(), darkTheme: ThemeData.dark(), - supportedLocales: const [Locale('en'), Locale('hi')], + supportedLocales: const [ + Locale('en'), + Locale('hi'), + Locale('fr'), + Locale('it'), + ], localizationsDelegates: GlobalStreamChatLocalizations.delegates, builder: (context, widget) => StreamChat( client: client, diff --git a/packages/stream_chat_flutter/lib/src/localization/translations.dart b/packages/stream_chat_flutter/lib/src/localization/translations.dart index 7ce7a507..6a7ac657 100644 --- a/packages/stream_chat_flutter/lib/src/localization/translations.dart +++ b/packages/stream_chat_flutter/lib/src/localization/translations.dart @@ -67,9 +67,9 @@ abstract class Translations { String get instantCommandsLabel; - String get fileTooLargeAfterCompressionError; + String fileTooLargeAfterCompressionError(double limitInMB); - String get fileTooLargeError; + String fileTooLargeError(double limitInMB); String emojiMatchingQueryText(String query); @@ -314,14 +314,14 @@ class DefaultTranslations implements Translations { String get instantCommandsLabel => 'Instant Commands'; @override - String get fileTooLargeAfterCompressionError => + String fileTooLargeAfterCompressionError(double limitInMB) => 'The file is too large to upload. ' - 'The file size limit is 20MB. ' + 'The file size limit is $limitInMB MB. ' 'We tried compressing it, but it was not enough.'; @override - String get fileTooLargeError => - 'The file is too large to upload. The file size limit is 20MB.'; + String fileTooLargeError(double limitInMB) => + 'The file is too large to upload. The file size limit is $limitInMB MB.'; @override String emojiMatchingQueryText(String query) => 'Emoji matching "$query"'; diff --git a/packages/stream_chat_flutter/lib/src/message_input.dart b/packages/stream_chat_flutter/lib/src/message_input.dart index 9d9ada07..7843e77e 100644 --- a/packages/stream_chat_flutter/lib/src/message_input.dart +++ b/packages/stream_chat_flutter/lib/src/message_input.dart @@ -1144,7 +1144,9 @@ class MessageInputState extends State { if (mediaInfo.filesize! > widget.maxAttachmentSize) { _showErrorAlert( - context.translations.fileTooLargeAfterCompressionError, + context.translations.fileTooLargeAfterCompressionError( + widget.maxAttachmentSize / (1024 * 1024), + ), ); return; } @@ -1155,7 +1157,9 @@ class MessageInputState extends State { path: mediaInfo.path, ); } else { - _showErrorAlert(context.translations.fileTooLargeError); + _showErrorAlert(context.translations.fileTooLargeError( + widget.maxAttachmentSize / (1024 * 1024), + )); return; } } @@ -1922,7 +1926,9 @@ class MessageInputState extends State { if (mediaInfo.filesize! > widget.maxAttachmentSize) { _showErrorAlert( - context.translations.fileTooLargeAfterCompressionError, + context.translations.fileTooLargeAfterCompressionError( + widget.maxAttachmentSize / (1024 * 1024), + ), ); return; } @@ -1933,7 +1939,9 @@ class MessageInputState extends State { path: mediaInfo.path, ); } else { - _showErrorAlert(context.translations.fileTooLargeError); + _showErrorAlert(context.translations.fileTooLargeError( + widget.maxAttachmentSize / (1024 * 1024), + )); return; } } diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart index 2cd88989..ba515e2f 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_en.dart @@ -115,14 +115,14 @@ class StreamChatLocalizationsEn extends GlobalStreamChatLocalizations { String get instantCommandsLabel => 'Instant Commands'; @override - String get fileTooLargeAfterCompressionError => + String fileTooLargeAfterCompressionError(double limitInMB) => 'The file is too large to upload. ' - 'The file size limit is 20MB. ' + 'The file size limit is $limitInMB MB. ' 'We tried compressing it, but it was not enough.'; @override - String get fileTooLargeError => - 'The file is too large to upload. The file size limit is 20MB.'; + String fileTooLargeError(double limitInMB) => + 'The file is too large to upload. The file size limit is $limitInMB MB.'; @override String emojiMatchingQueryText(String query) => 'Emoji matching "$query"'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart index 3c26a071..297fbc1a 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_fr.dart @@ -117,14 +117,14 @@ class StreamChatLocalizationsFr extends GlobalStreamChatLocalizations { String get instantCommandsLabel => 'Commandes instantanées'; @override - String get fileTooLargeAfterCompressionError => + String fileTooLargeAfterCompressionError(double limitInMB) => 'Le fichier est trop volumineux pour être téléchargé. ' - 'La taille maximale des fichiers est de 20 Mo. ' + 'La taille maximale des fichiers est de $limitInMB Mo. ' "Nous avons essayé de le compresser, mais ce n'était pas suffisant."; @override - String get fileTooLargeError => - 'Le fichier est trop volumineux pour être téléchargé. La taille limite du fichier est de 20 Mo.'; + String fileTooLargeError(double limitInMB) => + 'Le fichier est trop volumineux pour être téléchargé. La taille limite du fichier est de $limitInMB Mo.'; @override String emojiMatchingQueryText(String query) => diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart index e32b4a4d..c6e94e32 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_hi.dart @@ -115,14 +115,14 @@ class StreamChatLocalizationsHi extends GlobalStreamChatLocalizations { String get instantCommandsLabel => 'तत्काल आदेश'; @override - String get fileTooLargeAfterCompressionError => + String fileTooLargeAfterCompressionError(double limitInMB) => 'फ़ाइल अपलोड करने के लिए बहुत बड़ी है। ' - 'फ़ाइल आकार सीमा 20MB है। ' + 'फ़ाइल आकार सीमा $limitInMB MB है। ' 'हमने इसे कंप्रेस करने की कोशिश की, लेकिन यह काफी नहीं था।'; @override - String get fileTooLargeError => - 'फ़ाइल अपलोड करने के लिए बहुत बड़ी है। फ़ाइल आकार सीमा 20MB है।'; + String fileTooLargeError(double limitInMB) => + 'फ़ाइल अपलोड करने के लिए बहुत बड़ी है। फ़ाइल आकार सीमा $limitInMB MB है।'; @override String emojiMatchingQueryText(String query) => '"$query" से मिलते हुए इमोजी'; diff --git a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart index 0edcbd0a..8797de27 100644 --- a/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart +++ b/packages/stream_chat_localizations/lib/src/stream_chat_localizations_it.dart @@ -117,14 +117,14 @@ class StreamChatLocalizationsIt extends GlobalStreamChatLocalizations { String get instantCommandsLabel => 'Commandi istantanei'; @override - String get fileTooLargeAfterCompressionError => + String fileTooLargeAfterCompressionError(double limitInMB) => 'Il file è troppo grande per essere caricato. ' - 'Il file eccede il limite di 20MB. ' + 'Il file eccede il limite di $limitInMB MB. ' 'Abbiamo provato a comprimerlo, ma non è stato abbastanza.'; @override - String get fileTooLargeError => - 'Il file è troppo grande per essere caricato. Il limite è di 20MB.'; + String fileTooLargeError(double limitInMB) => ''' +Il file è troppo grande per essere caricato. Il limite è di $limitInMB MB.'''; @override String emojiMatchingQueryText(String query) => 'Emoji per "$query"';