From f14397ae11f47ee9ce90952fe41eb7ea7de1280a Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Thu, 8 Mar 2018 11:06:31 -0800 Subject: [PATCH] Correct DefaultMaterialLocalizations.delegate supported locales list (#15260) --- .../lib/src/material_localizations.dart | 15 +++++++++++++-- .../test/translations_test.dart | 5 +++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 4dcb82ead6..40f056740d 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -14,6 +14,10 @@ import 'l10n/date_localizations.dart' as date_localizations; import 'l10n/localizations.dart' show TranslationBundle, translationBundleForLocale; import 'widgets_localizations.dart'; +// Watch out: the supported locales list in the doc comment below must be kept +// in sync with the list we test, see test/translations_test.dart, and of course +// the acutal list of supported locales in _MaterialLocalizationsDelegate. + /// Localized strings for the material widgets. /// /// To include the localizations provided by this class in a [MaterialApp], @@ -493,22 +497,29 @@ void _loadDateIntlDataIfNotLoaded() { class _MaterialLocalizationsDelegate extends LocalizationsDelegate { const _MaterialLocalizationsDelegate(); + // Watch out: this list must match the one in the GlobalMaterialLocalizations + // class doc and the list we test, see test/translations_test.dart. static const List _supportedLanguages = const [ 'ar', // Arabic 'de', // German 'en', // English 'es', // Spanish - 'fa', // Farsi + 'fa', // Farsi (Persian) 'fr', // French 'he', // Hebrew 'it', // Italian 'ja', // Japanese + 'ko', // Korean + 'nl', // Dutch + 'pl', // Polish 'ps', // Pashto 'pt', // Portugese 'ro', // Romanian 'ru', // Russian + 'th', // Thai + 'tr', // Turkish 'ur', // Urdu - 'zh', // Simplified Chinese + 'zh', // Chinese (simplified) ]; @override diff --git a/packages/flutter_localizations/test/translations_test.dart b/packages/flutter_localizations/test/translations_test.dart index 18f342d0a9..d058732a93 100644 --- a/packages/flutter_localizations/test/translations_test.dart +++ b/packages/flutter_localizations/test/translations_test.dart @@ -7,6 +7,8 @@ import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { + // Watch out: this list must be kept in sync with the comment at the top of + // GlobalMaterialLocalizations. final List languages = [ 'ar', // Arabic 'de', // German @@ -33,6 +35,9 @@ void main() { for (String language in languages) { testWidgets('translations exist for $language', (WidgetTester tester) async { final Locale locale = new Locale(language, ''); + + expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); + final MaterialLocalizations localizations = new GlobalMaterialLocalizations(locale); expect(localizations.openAppDrawerTooltip, isNotNull);