m3_lightmeter/lib/data/models/supported_locale.dart

32 lines
713 B
Dart
Raw Normal View History

import 'package:intl/intl.dart';
2023-02-14 12:30:49 +00:00
enum SupportedLocale { en, fr, ru }
SupportedLocale get currentLanguage {
switch (Intl.getCurrentLocale()) {
case "en":
return SupportedLocale.en;
2023-02-14 12:30:49 +00:00
case "fr":
return SupportedLocale.fr;
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';
case SupportedLocale.ru:
return 'Русский';
}
}
}