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
- UI Docs
Changelog
Check out the changelog on pub.dev to see the latest changes in the package.
What is Localization?
If you deploy your app to users who speak another language, you'll need to internationalize (localize) it. That means you need to write the app in a way that makes it possible to localize values like text and layouts for each language or locale that the app supports. For more information, see the Flutter documentation.
What this package allows you to do is to provide localized strings for the Stream chat widgets. For example, depending on the application locale, the Stream Chat widgets will display the appropriate language. The locale will be set automatically, based on system preferences, or you could set it programmatically in your app. The package supports several different languages, with more to be added. The package allows you to override any supported language or add a new language that isn't supported.
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
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'),
Locale('es'),
Locale('ca'),
Locale('ja'),
Locale('ko'),
Locale('pt'),
Locale('de'),
Locale('no'),
],
// 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, create a new class extending GlobalStreamChatLocalizations
and create a delegate for it, adding it to the delegates
array.
Check out this example to see how to add a new language.
Override existing languages
To override an existing language, create a new class extending that particular language class and create a delegate for it, adding it to the delegates
array.
Check out 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>hi</string>
<string>fr</string>
<string>it</string>
<string>es</string>
<string>ca</string>
<string>ja</string>
<string>ko</string>
<string>pt</string>
<string>de</string>
<string>no</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.
Libraries
- stream_chat_localizations
- Localizations for the StreamChat Flutter library.