2021-02-27 17:02:55 +01:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
2021-02-27 14:39:58 +01:00
|
|
|
|
export 'package:flutter_gen/gen_l10n/l10n.dart';
|
2021-03-01 09:44:37 +01:00
|
|
|
|
|
2021-03-09 08:51:08 +01:00
|
|
|
|
export 'l10n_api.dart';
|
2021-03-01 00:02:32 +01:00
|
|
|
|
export 'l10n_from_string.dart';
|
2021-02-27 17:02:55 +01:00
|
|
|
|
|
|
|
|
|
abstract class LocaleSerde {
|
2021-04-11 00:55:04 +02:00
|
|
|
|
static Locale fromJson(String? json) {
|
|
|
|
|
if (json == null) return const Locale('en');
|
2021-02-27 17:02:55 +01:00
|
|
|
|
|
|
|
|
|
final lang = json.split('-');
|
|
|
|
|
|
|
|
|
|
return Locale(lang[0], lang.length > 1 ? lang[1] : null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static String toJson(Locale locale) => locale.toLanguageTag();
|
|
|
|
|
}
|
2021-03-04 09:46:08 +01:00
|
|
|
|
|
|
|
|
|
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',
|
2021-04-27 22:42:52 +02:00
|
|
|
|
'sr': 'Српски',
|
|
|
|
|
'zh_Hant': '繁體中文',
|
|
|
|
|
'nb': 'Norwegian',
|
|
|
|
|
'nb_NO': 'Norwegian Bokmål',
|
|
|
|
|
'bg': 'български',
|
2021-03-04 09:46:08 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
extension LanguageName on Locale {
|
|
|
|
|
/// returns the name of the language in the given language
|
|
|
|
|
String get languageName => _languageNames[toString()] ?? toString();
|
|
|
|
|
}
|