Official Localizations for Stream Chat Flutter library.
The Official localizations for Stream Chat Flutter, a service for building chat applications.
Quick Links
- Register to get an API key for Stream Chat
- Flutter Chat Tutorial
- Chat UI Kit
This package provides localized strings for the stream chat widgets for many languages.
Changelog
Check out the changelog on pub.dev to see the latest changes in the package.
Supported languages
At the moment we support the following languages:
More languages will be added in the future. Feel free to contribute to add more languages.
Add dependency
Add this to your package's pubspec.yaml file, use the latest version
dependencies:
stream_chat_localizations: ^latest_version
You should then run flutter packages get
Usage
import 'package:flutter/material.dart';
import 'package:stream_chat_localizations/stream_chat_localizations.dart';
void main() {
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// Add all the supported locales
supportedLocales: const [
Locale('en'),
Locale('hi'),
Locale('fr'),
Locale('it'),
],
// Add GlobalStreamChatLocalizations.delegates
localizationsDelegates: GlobalStreamChatLocalizations.delegates,
builder: (context, widget) => StreamChat(
client: client,
child: widget,
),
home: StreamChannel(
channel: channel,
child: const ChannelPage(),
),
);
}
}
Adding a new language
To add a new language, you need to create a new class extending GlobalStreamChatLocalizations and create a delegate for it adding it to the delegates array.
Checkout this example to see how to add a new language.
Override exisiting languages
To override an existing language, you need to create a new class extending that particular language class and create a delegate for it adding it to the delegates array.
Checkout this example to see how to override an existing language.
⚠️ Note on iOS
For translation to work on iOS you need to add supported locales to
ios/Runner/Info.plist as described here.
Example:
<key>CFBundleLocalizations</key>
<array>
<string>en</string>
<string>nb</string>
<string>fr</string>
<string>it</string>
</array>
Contributing
We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are pleased to merge your code into the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.