m3_lightmeter/lib/data/models/supported_locale.dart
Vadim 485636c706
ML-28 Implement language picker (#29)
* added language picker

* Create intl_ru.arb

* Update README.md
2023-02-11 22:19:18 +03:00

28 lines
603 B
Dart

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