Add language names

This commit is contained in:
shilangyu 2021-03-04 09:46:08 +01:00
parent 4262cab230
commit 0adea8f0a9
2 changed files with 44 additions and 1 deletions

View File

@ -15,3 +15,46 @@ abstract class LocaleSerde {
static String toJson(Locale locale) => locale.toLanguageTag(); static String toJson(Locale locale) => locale.toLanguageTag();
} }
const _languageNames = {
'ca': 'Català',
'ar': 'عربي',
'en': 'English',
'el': 'Ελληνικά',
'eu': 'Euskara',
'eo': 'Esperanto',
'es': 'Español',
'da': 'Dansk',
'de': 'Deutsch',
'ga': 'Gaeilge',
'gl': 'Galego',
'hr': 'hrvatski',
'hu': 'Magyar Nyelv',
'ka': 'ქართული ენა',
'ko': '한국어',
'km': 'ភាសាខ្មែរ',
'hi': 'मानक हिन्दी',
'fa': 'فارسی',
'ja': '日本語',
'oc': 'Occitan',
'pl': 'Polski',
'pt': 'Português',
'pt_BR': 'Português Brasileiro',
'zh': '中文',
'fi': 'Suomi',
'fr': 'Français',
'sv': 'Svenska',
'sq': 'Shqip',
'sr_Latn': 'srpski',
'th': 'ภาษาไทย',
'tr': 'Türkçe',
'uk': 'Українська Mова',
'ru': 'Русский',
'nl': 'Nederlands',
'it': 'Italiano',
};
extension LanguageName on Locale {
/// returns the name of the language in the given language
String get languageName => _languageNames[toString()] ?? toString();
}

View File

@ -86,7 +86,7 @@ class AppearanceConfigPage extends HookWidget {
title: 'Choose language', title: 'Choose language',
groupValue: configStore.locale, groupValue: configStore.locale,
values: L10n.supportedLocales, values: L10n.supportedLocales,
// TODO: add actual language names mapValueToString: (locale) => locale.languageName,
onChanged: (selected) { onChanged: (selected) {
configStore.locale = selected; configStore.locale = selected;
}, },