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