From 0adea8f0a9d54775b466146c2e37f183196bf576 Mon Sep 17 00:00:00 2001 From: shilangyu Date: Thu, 4 Mar 2021 09:46:08 +0100 Subject: [PATCH] Add language names --- lib/l10n/l10n.dart | 43 +++++++++++++++++++++++++++++++++++++++++ lib/pages/settings.dart | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/lib/l10n/l10n.dart b/lib/l10n/l10n.dart index ae1acfb..4211997 100644 --- a/lib/l10n/l10n.dart +++ b/lib/l10n/l10n.dart @@ -15,3 +15,46 @@ abstract class LocaleSerde { 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(); +} diff --git a/lib/pages/settings.dart b/lib/pages/settings.dart index 43aa7cb..5e8c53f 100644 --- a/lib/pages/settings.dart +++ b/lib/pages/settings.dart @@ -86,7 +86,7 @@ class AppearanceConfigPage extends HookWidget { title: 'Choose language', groupValue: configStore.locale, values: L10n.supportedLocales, - // TODO: add actual language names + mapValueToString: (locale) => locale.languageName, onChanged: (selected) { configStore.locale = selected; },