forked from maelchiotti/LocalMaterialNotes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupported_language.dart
More file actions
64 lines (45 loc) · 1.56 KB
/
supported_language.dart
File metadata and controls
64 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import 'package:dart_helper_utils/dart_helper_utils.dart';
import 'package:flutter/material.dart';
import 'package:locale_names/locale_names.dart';
/// Languages supported by the application.
enum SupportedLanguage {
/// Czech.
cs(Locale('cs'), 1),
/// English.
en(Locale('en'), 1),
/// Spanish.
es(Locale('es'), .97),
/// French.
fr(Locale('fr'), 1),
/// German.
de(Locale('de'), .97),
/// Hindi.
hi(Locale('hi'), .80),
/// Italian.
it(Locale('it'), .99),
/// Polish.
pl(Locale('pl'), .61),
/// Portuguese.
pt(Locale('pt'), .62),
/// Russian.
ru(Locale('ru'), .88),
/// Turkish.
tr(Locale('tr'), .80),
/// Chinese Simplified.
zh(Locale('zh'), 1),
/// Chinese Traditional.
zhTW(Locale.fromSubtags(languageCode: 'zh', scriptCode: 'Hant'), 0),
;
/// The locale completion of this language.
final Locale locale;
/// The translation completion of this language.
final num completion;
/// A language supported by the application with its [locale] and its translation [completion].
const SupportedLanguage(this.locale, this.completion);
/// Returns the list of [locale] supported by the application.
static List<Locale> locales = values.map((language) => language.locale).toList();
/// Returns the native name of this language.
String get nativeName => locale.nativeDisplayLanguage.capitalizeFirstLetter;
/// Returns the translation completion of this language formatted as a percentage according to the [locale].
String get completionFormatted => completion.formatAsPercentage(locale: locale.languageCode);
}