m3_lightmeter/lib/data/models/supported_locale.dart
Vadim 5602b1ed80
ML-70 Migrate to Dart 3 + stricter lints (#71)
* updated pub version

* added lint

* --code=always_use_package_imports

* dart fixes

* format

* other lints
2023-05-11 15:30:18 +02:00

31 lines
713 B
Dart

import 'package:intl/intl.dart';
enum SupportedLocale { en, fr, ru }
SupportedLocale get currentLanguage {
switch (Intl.getCurrentLocale()) {
case "en":
return SupportedLocale.en;
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';
case SupportedLocale.fr:
return 'Français';
case SupportedLocale.ru:
return 'Русский';
}
}
}