From 48d1eecf8c9b4a268c837bf86f7711fc20321506 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Jul 2021 11:28:22 +0200 Subject: [PATCH 1/3] docs(localization): add flutter docs link --- docusaurus/docs/Flutter/guides/adding_localization.mdx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docusaurus/docs/Flutter/guides/adding_localization.mdx b/docusaurus/docs/Flutter/guides/adding_localization.mdx index e8f0dfa5..abbd9e70 100644 --- a/docusaurus/docs/Flutter/guides/adding_localization.mdx +++ b/docusaurus/docs/Flutter/guides/adding_localization.mdx @@ -32,7 +32,8 @@ You should then run `flutter packages get` ### Usage -Flutter generally and the Stream Chat SDK will use the system locale of the users device, if that locale is supported (see below), if the locale is not supported we will default to `en` +Flutter generally and the Stream Chat SDK will use the system locale of the users device, if that locale is supported (see below), if the locale is not supported we will default to `en`. +Make sure to read more about localization in the [official Flutter docs](https://flutter.dev/docs/development/accessibility-and-localization/internationalization). ```dart import 'package:flutter/material.dart'; From fc5e3add5de42751ae7a898ae1d04c0b59e5a366 Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Jul 2021 11:39:15 +0200 Subject: [PATCH 2/3] fix analysis --- packages/stream_chat_flutter/lib/src/stream_chat.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/stream_chat_flutter/lib/src/stream_chat.dart b/packages/stream_chat_flutter/lib/src/stream_chat.dart index b3654a31..f185d288 100644 --- a/packages/stream_chat_flutter/lib/src/stream_chat.dart +++ b/packages/stream_chat_flutter/lib/src/stream_chat.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:ui' as ui; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; From 76074b4774d93d8ac2e34352b74b0b09e38f3e4b Mon Sep 17 00:00:00 2001 From: Salvatore Giordano Date: Thu, 29 Jul 2021 11:47:25 +0200 Subject: [PATCH 3/3] fix code snippet and add comments --- .../docs/Flutter/guides/adding_localization.mdx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docusaurus/docs/Flutter/guides/adding_localization.mdx b/docusaurus/docs/Flutter/guides/adding_localization.mdx index abbd9e70..5645e811 100644 --- a/docusaurus/docs/Flutter/guides/adding_localization.mdx +++ b/docusaurus/docs/Flutter/guides/adding_localization.mdx @@ -98,17 +98,23 @@ Here is an example of how that would look like: Locale('fr'), Locale('it'), ], + // locales are the locales of the device + // supportedLocales are the app supported locales localeListResolutionCallback: (locales, supportedLocales) { + // We map the supported locales to language codes + // note that this is completely optional and this logic can be changed as you like final supportedLanguageCodes = supportedLocales.map((e) => e.languageCode); if (locales != null) { - for (final locale in locales) { - if (supportedLanguageCodes.contains(locale.languageCode)) { - return locale; + // we iterate over the locales and find the first one that is supported + for (final locale in locales) { + if (supportedLanguageCodes.contains(locale.languageCode)) { + return locale; + } } } - } + // if we didn't find a supported language, we return the italian language return const Locale('it'); }, // Add GlobalStreamChatLocalizations.delegates @@ -117,7 +123,7 @@ Here is an example of how that would look like: ``` -In this case we're using Italian as the default language. +In this case we're using italian as the default language. ### ⚠️ Note on **iOS**