Files
eatvio_app/lib/core/utils/localization_utils.dart
2025-04-04 20:21:31 +07:00

74 lines
1.8 KiB
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;
}
}
String getMinuteForm(int number) {
if (number % 10 == 1 && number % 100 != 11) {
return S.current.minute;
} else if ([2, 3, 4].contains(number % 10) && ![12, 13, 14].contains(number % 100)) {
return S.current.minutes;
} else {
return S.current.another_form_of_minute;
}
}
String getHourForm(int number) {
if (number % 10 == 1 && number % 100 != 11) {
return S.current.hour;
} else if ([2, 3, 4].contains(number % 10) && ![12, 13, 14].contains(number % 100)) {
return S.current.another_form_of_hour;
} else {
return S.current.hours;
}
}
String getStepForm(int number) {
if (number % 10 == 1 && number % 100 != 11) {
return S.current.stage;
} else if ([2, 3, 4].contains(number % 10) && ![12, 13, 14].contains(number % 100)) {
return S.current.another_form_of_stage;
} else {
return S.current.stages;
}
}