comparison src/gui/translate/anime.cc @ 90:c4bb49c2f6eb

config: improve handling of vars : )
author Paper <mrpapersonic@gmail.com>
date Tue, 31 Oct 2023 23:41:53 -0400
parents 9b2b41f83a5e
children f88eda79c60a
comparison
equal deleted inserted replaced
89:e6fab256ddc4 90:c4bb49c2f6eb
5 5
6 namespace Translate { 6 namespace Translate {
7 7
8 std::string ToString(const Anime::ListStatus status) { 8 std::string ToString(const Anime::ListStatus status) {
9 switch (status) { 9 switch (status) {
10 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list"));
11 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching")); 10 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching"));
12 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch")); 11 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch"));
13 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed")); 12 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed"));
14 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped")); 13 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped"));
15 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold")); 14 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold"));
16 default: return ""; 15 default:
16 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list"));
17 } 17 }
18 } 18 }
19 19
20 std::string ToString(const Anime::SeriesFormat format) { 20 std::string ToString(const Anime::SeriesFormat format) {
21 switch (format) { 21 switch (format) {
22 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
23 case Anime::SeriesFormat::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV")); 22 case Anime::SeriesFormat::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV"));
24 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short")); 23 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short"));
25 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA")); 24 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA"));
26 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie")); 25 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie"));
27 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special")); 26 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special"));
28 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA")); 27 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA"));
29 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music")); 28 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music"));
30 default: return ""; 29 default:
30 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
31 } 31 }
32 } 32 }
33 33
34 std::string ToString(const Anime::SeriesSeason season) { 34 std::string ToString(const Anime::SeriesSeason season) {
35 switch (season) { 35 switch (season) {
36 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
37 case Anime::SeriesSeason::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter")); 36 case Anime::SeriesSeason::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter"));
38 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer")); 37 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer"));
39 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall")); 38 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall"));
40 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring")); 39 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring"));
41 default: return ""; 40 default:
41 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
42 } 42 }
43 } 43 }
44 44
45 std::string ToString(const Anime::SeriesStatus status) { 45 std::string ToString(const Anime::SeriesStatus status) {
46 switch (status) { 46 switch (status) {
47 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
48 case Anime::SeriesStatus::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing")); 47 case Anime::SeriesStatus::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing"));
49 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing")); 48 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing"));
50 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired")); 49 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired"));
51 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled")); 50 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled"));
52 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus")); 51 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus"));
53 default: return ""; 52 default:
53 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown"));
54 } 54 }
55 } 55 }
56 56
57 std::string ToString(const Anime::Services service) {
58 switch (service) {
59 case Anime::Services::ANILIST: return Strings::ToUtf8String(QCoreApplication::tr("AniList"));
60 default:
61 case Anime::Services::NONE: return Strings::ToUtf8String(QCoreApplication::tr("None"));
62 }
63 }
64
65 Anime::Services ToService(const std::string& str) {
66 const std::unordered_map<std::string, Anime::Services> map = {
67 {"None", Anime::Services::NONE },
68 {"AniList", Anime::Services::ANILIST}
69 };
70
71 if (map.find(str) == map.end())
72 return Anime::Services::NONE;
73 return map.at(str);
74 }
75
76 std::string ToString(const Anime::TitleLanguage language) {
77 switch (language) {
78 case Anime::TitleLanguage::NATIVE: return Strings::ToUtf8String(QCoreApplication::tr("Native"));
79 case Anime::TitleLanguage::ENGLISH: return Strings::ToUtf8String(QCoreApplication::tr("English"));
80 default:
81 case Anime::TitleLanguage::ROMAJI: return Strings::ToUtf8String(QCoreApplication::tr("Romaji"));
82 }
83 }
84
85 Anime::TitleLanguage ToLanguage(const std::string& str) {
86 const std::unordered_map<std::string, Anime::TitleLanguage> map = {
87 {"Romaji", Anime::TitleLanguage::ROMAJI},
88 {"Native", Anime::TitleLanguage::NATIVE},
89 {"English", Anime::TitleLanguage::ENGLISH}
90 };
91
92 if (map.find(str) == map.end())
93 return Anime::TitleLanguage::ROMAJI;
94 return map.at(str);
95 }
96
57 } // namespace Translate 97 } // namespace Translate