main
 1import 'package:flutter/material.dart';
 2
 3/// Selects the correct display name for a specific language code.
 4String getDisplayLanguage(Locale l) => switch(l.toLanguageTag()) {
 5  'en' => 'English',
 6  'en-US' => 'English (US)',
 7  'de' => 'Deutsch',
 8  'es' => 'Español',
 9  'fr' => 'Française',
10  'it' => 'Italiano',
11  'nb' => 'Norsk bokmål',
12  'nl' => 'Nederlands',
13  'pl' => 'Polski',
14  'pt' => 'Português',
15  'pt-BR' => 'Português (Brasil)',
16  'ru' => 'Русский',
17  'tr' => 'Türkçe',
18  'sv' => 'Svenska',
19  'zh' => '中文 (简体)',
20  'zh-Hant' => '中文(繁體)',
21  'hu' => 'Magyar (Magyarország)',
22  'et' => 'Eesti (Eesti)',
23  'cs' => 'Čeština',
24  'ta' => 'தமிழ்',
25  'sl' => 'Slovenščina',
26  'lt' => 'Lietuvių',
27  // Websites with names for expanding when new languages get added:
28  // - https://chronoplexsoftware.com/localisation/help/languagecodes.htm
29  // - https://localizely.com/locale-code/zh-Hans/
30  //
31  // Names should be modified so they start with an upper case letter.
32  //
33  (_) => (){
34    debugPrint('Unlocalized language tag: $l');
35    debugPrintStack();
36    assert(false, 'Should only be called for localized strings and all '
37        'localized strings are tested.');
38    return l.languageCode;
39  }()
40};