Files
eatvio_app/lib/core/utils/localization_utils.dart
2024-11-11 21:10:38 +07:00

44 lines
1013 B
Dart

import 'package:eatvio_app/features/feed/models/diets_pagination_model.dart';
import 'package:eatvio_app/generated/l10n.dart';
String getLocalizedMeasurementUnits(S s, Portion portion) {
switch (portion) {
case Portion.GRAMS:
return s.gr;
case Portion.MILLILITERS:
return s.milliliter;
case Portion.PCS:
return s.pcs;
}
}
String getDayForm(int number, S s) {
if (number % 100 >= 11 && number % 100 <= 14) {
return s.days;
}
int lastDigit = number % 10;
if (lastDigit == 1) {
return s.day.toLowerCase();
} else if (lastDigit >= 2 && lastDigit <= 4) {
return s.another_form_of_day;
} else {
return s.days;
}
}
String getCommentForm(int number, S s) {
if (number % 100 >= 11 && number % 100 <= 14) {
return s.comments_plural;
}
int lastDigit = number % 10;
if (lastDigit == 1) {
return s.comment;
} else if (lastDigit >= 2 && lastDigit <= 4) {
return s.another_form_of_comment;
} else {
return s.comments_plural;
}
}