lemmur-app-android/lib/l10n/l10n_api.dart

72 lines
2.0 KiB
Dart
Raw Normal View History

2021-03-09 08:51:08 +01:00
import 'package:flutter/material.dart';
2021-04-05 20:14:39 +02:00
import 'package:lemmy_api_client/v3.dart';
2021-03-09 08:51:08 +01:00
import 'gen/l10n.dart';
2021-03-09 08:51:08 +01:00
extension SortTypeL10n on SortType {
String tr(BuildContext context) {
switch (this) {
case SortType.hot:
return L10n.of(context).hot;
2021-03-09 08:51:08 +01:00
case SortType.new_:
return L10n.of(context).new_;
2021-03-09 08:51:08 +01:00
case SortType.topYear:
return L10n.of(context).top_year;
2021-03-09 08:51:08 +01:00
case SortType.topMonth:
return L10n.of(context).top_month;
2021-03-09 22:21:14 +01:00
case SortType.topWeek:
return L10n.of(context).top_week;
2021-03-09 08:51:08 +01:00
case SortType.topDay:
return L10n.of(context).top_day;
2021-03-09 08:51:08 +01:00
case SortType.topAll:
return L10n.of(context).top_all;
2021-03-09 08:51:08 +01:00
case SortType.newComments:
return L10n.of(context).new_comments;
2021-03-09 08:51:08 +01:00
case SortType.active:
return L10n.of(context).active;
2021-03-09 08:51:08 +01:00
case SortType.mostComments:
return L10n.of(context).most_comments;
2021-03-09 08:51:08 +01:00
default:
2021-03-09 22:21:14 +01:00
throw Exception('unreachable');
2021-03-09 08:51:08 +01:00
}
}
}
extension PostListingTypeL10n on PostListingType {
String tr(BuildContext context) {
switch (this) {
case PostListingType.all:
return L10n.of(context).all;
2021-03-09 08:51:08 +01:00
case PostListingType.community:
return L10n.of(context).community;
2021-03-09 08:51:08 +01:00
case PostListingType.local:
return L10n.of(context).local;
2021-03-09 08:51:08 +01:00
case PostListingType.subscribed:
return L10n.of(context).subscribed;
2021-03-09 08:51:08 +01:00
default:
throw Exception('unreachable');
}
}
}
extension SearchTypeL10n on SearchType {
String tr(BuildContext context) {
switch (this) {
case SearchType.all:
return L10n.of(context).all;
2021-03-09 08:51:08 +01:00
case SearchType.comments:
return L10n.of(context).comments;
2021-03-09 08:51:08 +01:00
case SearchType.communities:
return L10n.of(context).communities;
2021-03-09 08:51:08 +01:00
case SearchType.posts:
return L10n.of(context).posts;
2021-03-09 08:51:08 +01:00
case SearchType.url:
return L10n.of(context).url;
2021-03-09 08:51:08 +01:00
case SearchType.users:
return L10n.of(context).users;
2021-03-09 08:51:08 +01:00
default:
throw Exception('unreachable');
}
}
}