Remove json translations approach, add example for adding language
Signed-off-by: Sahil Kumar <[email protected]>
This commit is contained in:
@@ -104,11 +104,7 @@ extension BuildContextX on BuildContext {
|
||||
double get textScaleFactor =>
|
||||
MediaQuery.maybeOf(this)?.textScaleFactor ?? 1.0;
|
||||
|
||||
String translate({
|
||||
required String key,
|
||||
required String defaultValue,
|
||||
}) =>
|
||||
StreamChatLocalizations.of(this)?.translate(key) ?? defaultValue;
|
||||
StreamChatLocalizations? get translations => StreamChatLocalizations.of(this);
|
||||
}
|
||||
|
||||
/// Extension on [BorderRadius]
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_markdown/flutter_markdown.dart';
|
||||
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
|
||||
import 'package:stream_chat_flutter_core/stream_chat_flutter_core.dart';
|
||||
import 'package:stream_chat_flutter/src/extension.dart';
|
||||
|
||||
/// Text widget to display in message
|
||||
class MessageText extends StatelessWidget {
|
||||
@@ -29,6 +30,8 @@ class MessageText extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final texts = context.translations?.launchUrlError ?? 'defaultValue';
|
||||
return Text(texts);
|
||||
final text = _replaceMentions(message.text ?? '').replaceAll('\n', '\n\n');
|
||||
|
||||
final themeData = Theme.of(context);
|
||||
|
||||
@@ -71,9 +71,6 @@ import 'package:flutter/widgets.dart';
|
||||
/// * [GlobalStreamChatLocalizations], which provides material localizations
|
||||
/// for many languages.
|
||||
abstract class StreamChatLocalizations {
|
||||
///
|
||||
String? translate(String key);
|
||||
|
||||
/// The `StreamChatLocalizations` from the closest [Localizations] instance
|
||||
/// that encloses the given context.
|
||||
///
|
||||
@@ -94,4 +91,6 @@ abstract class StreamChatLocalizations {
|
||||
context,
|
||||
StreamChatLocalizations,
|
||||
);
|
||||
|
||||
String get launchUrlError;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user