Mercurial > minori
comparison src/gui/translate/anime.cc @ 174:f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 29 Nov 2023 13:53:56 -0500 |
parents | c4bb49c2f6eb |
children | 9b10175be389 |
comparison
equal
deleted
inserted
replaced
173:de0a8d2f28b3 | 174:f88eda79c60a |
---|---|
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::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching")); | 10 case Anime::ListStatus::CURRENT: return "Currently watching"; |
11 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch")); | 11 case Anime::ListStatus::PLANNING: return "Plan to watch"; |
12 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed")); | 12 case Anime::ListStatus::COMPLETED: return "Completed"; |
13 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped")); | 13 case Anime::ListStatus::DROPPED: return "Dropped"; |
14 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold")); | 14 case Anime::ListStatus::PAUSED: return "On hold"; |
15 default: | 15 default: |
16 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list")); | 16 case Anime::ListStatus::NOT_IN_LIST: return "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::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV")); | 22 case Anime::SeriesFormat::TV: return "TV"; |
23 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short")); | 23 case Anime::SeriesFormat::TV_SHORT: return "TV short"; |
24 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA")); | 24 case Anime::SeriesFormat::OVA: return "OVA"; |
25 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie")); | 25 case Anime::SeriesFormat::MOVIE: return "Movie"; |
26 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special")); | 26 case Anime::SeriesFormat::SPECIAL: return "Special"; |
27 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA")); | 27 case Anime::SeriesFormat::ONA: return "ONA"; |
28 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music")); | 28 case Anime::SeriesFormat::MUSIC: return "Music"; |
29 default: | 29 default: |
30 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | 30 case Anime::SeriesFormat::UNKNOWN: return "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::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter")); | 36 case Anime::SeriesSeason::WINTER: return "Winter"; |
37 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer")); | 37 case Anime::SeriesSeason::SUMMER: return "Summer"; |
38 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall")); | 38 case Anime::SeriesSeason::FALL: return "Fall"; |
39 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring")); | 39 case Anime::SeriesSeason::SPRING: return "Spring"; |
40 default: | 40 default: |
41 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | 41 case Anime::SeriesSeason::UNKNOWN: return "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::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing")); | 47 case Anime::SeriesStatus::RELEASING: return "Currently airing"; |
48 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing")); | 48 case Anime::SeriesStatus::FINISHED: return "Finished airing"; |
49 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired")); | 49 case Anime::SeriesStatus::NOT_YET_RELEASED: return "Not yet aired"; |
50 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled")); | 50 case Anime::SeriesStatus::CANCELLED: return "Cancelled"; |
51 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus")); | 51 case Anime::SeriesStatus::HIATUS: return "On hiatus"; |
52 default: | 52 default: |
53 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | 53 case Anime::SeriesStatus::UNKNOWN: "Unknown"; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 std::string ToString(const Anime::Services service) { | 57 Anime::SeriesStatus ToListStatus(const std::string& str) { |
58 switch (service) { | 58 const std::unordered_map<std::string, Anime::SeriesStatus> map = { |
59 case Anime::Services::ANILIST: return Strings::ToUtf8String(QCoreApplication::tr("AniList")); | 59 {"Currently watching", Anime::SeriesSeason::CURRENT}, |
60 default: | 60 {"Plan to watch", Anime::SeriesSeason::PLANNING}, |
61 case Anime::Services::NONE: return Strings::ToUtf8String(QCoreApplication::tr("None")); | 61 {"Completed", Anime::SeriesSeason::COMPLETED}, |
62 } | 62 {"Dropped", Anime::SeriesSeason::DROPPED}, |
63 {"On hold", Anime::SeriesSeason::PAUSED} | |
64 }; | |
65 | |
66 if (map.find(str) == map.end()) | |
67 return Anime::SeriesStatus::NOT_IN_LIST; | |
68 return map.at(str); | |
69 } | |
70 | |
71 Anime::SeriesStatus ToSeriesStatus(const std::string& str) { | |
72 const std::unordered_map<std::string, Anime::SeriesStatus> map = { | |
73 {"Currently airing", Anime::SeriesSeason::RELEASING}, | |
74 {"Finished airing", Anime::SeriesSeason::FINISHED}, | |
75 {"Not yet aired", Anime::SeriesSeason::NOT_YET_RELEASED}, | |
76 {"Cancelled", Anime::SeriesSeason::CANCELLED}, | |
77 {"On hiatus", Anime::SeriesSeason::HIATUS} | |
78 }; | |
79 | |
80 if (map.find(str) == map.end()) | |
81 return Anime::SeriesStatus::UNKNOWN; | |
82 return map.at(str); | |
83 } | |
84 | |
85 Anime::SeriesSeason ToSeriesSeason(const std::string& str) { | |
86 const std::unordered_map<std::string, Anime::SeriesSeason> map = { | |
87 {"Winter", Anime::SeriesSeason::WINTER}, | |
88 {"Summer", Anime::SeriesSeason::SUMMER}, | |
89 {"Fall", Anime::SeriesSeason::FALL}, | |
90 {"Spring", Anime::SeriesSeason::SPRING} | |
91 }; | |
92 | |
93 if (map.find(str) == map.end()) | |
94 return Anime::SeriesSeason::UNKNOWN; | |
95 return map.at(str); | |
63 } | 96 } |
64 | 97 |
65 Anime::Services ToService(const std::string& str) { | 98 Anime::Services ToService(const std::string& str) { |
66 const std::unordered_map<std::string, Anime::Services> map = { | 99 const std::unordered_map<std::string, Anime::Services> map = { |
67 {"None", Anime::Services::NONE }, | |
68 {"AniList", Anime::Services::ANILIST} | 100 {"AniList", Anime::Services::ANILIST} |
69 }; | 101 }; |
70 | 102 |
71 if (map.find(str) == map.end()) | 103 if (map.find(str) == map.end()) |
72 return Anime::Services::NONE; | 104 return Anime::Services::NONE; |
73 return map.at(str); | 105 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 } | 106 } |
84 | 107 |
85 Anime::TitleLanguage ToLanguage(const std::string& str) { | 108 Anime::TitleLanguage ToLanguage(const std::string& str) { |
86 const std::unordered_map<std::string, Anime::TitleLanguage> map = { | 109 const std::unordered_map<std::string, Anime::TitleLanguage> map = { |
87 {"Romaji", Anime::TitleLanguage::ROMAJI}, | 110 {"Romaji", Anime::TitleLanguage::ROMAJI}, |
92 if (map.find(str) == map.end()) | 115 if (map.find(str) == map.end()) |
93 return Anime::TitleLanguage::ROMAJI; | 116 return Anime::TitleLanguage::ROMAJI; |
94 return map.at(str); | 117 return map.at(str); |
95 } | 118 } |
96 | 119 |
120 /* Localized versions of ToString() functions */ | |
121 | |
122 std::string ToLocalString(const Anime::ListStatus status) { | |
123 switch (status) { | |
124 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching")); | |
125 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch")); | |
126 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed")); | |
127 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped")); | |
128 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold")); | |
129 default: | |
130 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list")); | |
131 } | |
132 } | |
133 | |
134 std::string ToLocalString(const Anime::SeriesFormat format) { | |
135 switch (format) { | |
136 case Anime::SeriesFormat::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV")); | |
137 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short")); | |
138 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA")); | |
139 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie")); | |
140 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special")); | |
141 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA")); | |
142 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music")); | |
143 default: | |
144 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | |
145 } | |
146 } | |
147 | |
148 std::string ToLocalString(const Anime::SeriesSeason season) { | |
149 switch (season) { | |
150 case Anime::SeriesSeason::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter")); | |
151 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer")); | |
152 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall")); | |
153 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring")); | |
154 default: | |
155 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | |
156 } | |
157 } | |
158 | |
159 std::string ToLocalString(const Anime::SeriesStatus status) { | |
160 switch (status) { | |
161 case Anime::SeriesStatus::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing")); | |
162 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing")); | |
163 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired")); | |
164 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled")); | |
165 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus")); | |
166 default: | |
167 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); | |
168 } | |
169 } | |
170 | |
171 std::string ToLocalString(const Anime::Services service) { | |
172 switch (service) { | |
173 case Anime::Services::ANILIST: return Strings::ToUtf8String(QCoreApplication::tr("AniList")); | |
174 default: | |
175 case Anime::Services::NONE: return Strings::ToUtf8String(QCoreApplication::tr("None")); | |
176 } | |
177 } | |
178 | |
179 std::string ToLocalString(const Anime::TitleLanguage language) { | |
180 switch (language) { | |
181 case Anime::TitleLanguage::NATIVE: return Strings::ToUtf8String(QCoreApplication::tr("Native")); | |
182 case Anime::TitleLanguage::ENGLISH: return Strings::ToUtf8String(QCoreApplication::tr("English")); | |
183 default: | |
184 case Anime::TitleLanguage::ROMAJI: return Strings::ToUtf8String(QCoreApplication::tr("Romaji")); | |
185 } | |
186 } | |
187 | |
97 } // namespace Translate | 188 } // namespace Translate |