2023-02-11 19:19:18 +00:00
|
|
|
import 'package:intl/intl.dart';
|
|
|
|
|
2023-02-14 12:30:49 +00:00
|
|
|
enum SupportedLocale { en, fr, ru }
|
2023-02-11 19:19:18 +00:00
|
|
|
|
|
|
|
SupportedLocale get currentLanguage {
|
|
|
|
switch (Intl.getCurrentLocale()) {
|
|
|
|
case "en":
|
|
|
|
return SupportedLocale.en;
|
2023-02-14 12:30:49 +00:00
|
|
|
case "fr":
|
|
|
|
return SupportedLocale.fr;
|
2023-02-11 19:19:18 +00:00
|
|
|
case "ru":
|
|
|
|
return SupportedLocale.ru;
|
|
|
|
default:
|
|
|
|
return SupportedLocale.en;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extension SupportedLocaleExtension on SupportedLocale {
|
|
|
|
String get intlName => toString().replaceAll("SupportedLocale.", "");
|
|
|
|
|
|
|
|
String get localizedName {
|
|
|
|
switch (this) {
|
|
|
|
case SupportedLocale.en:
|
|
|
|
return 'English';
|
2023-02-14 12:30:49 +00:00
|
|
|
case SupportedLocale.fr:
|
|
|
|
return 'Français';
|
2023-02-11 19:19:18 +00:00
|
|
|
case SupportedLocale.ru:
|
|
|
|
return 'Русский';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|