comparison src/gui/translate/anime.cc @ 185:62e336597bb7

anime list: add support for different score formats
author Paper <mrpapersonic@gmail.com>
date Tue, 05 Dec 2023 13:45:23 -0500
parents 9b10175be389
children 9613d72b097e
comparison
equal deleted inserted replaced
184:09492158bcc5 185:62e336597bb7
69 default: 69 default:
70 case Anime::TitleLanguage::ROMAJI: return "Romaji"; 70 case Anime::TitleLanguage::ROMAJI: return "Romaji";
71 } 71 }
72 } 72 }
73 73
74 std::string ToString(const Anime::ScoreFormat format) {
75 switch (format) {
76 case Anime::ScoreFormat::POINT_3: return "POINT_3";
77 case Anime::ScoreFormat::POINT_5: return "POINT_5";
78 case Anime::ScoreFormat::POINT_10: return "POINT_10";
79 case Anime::ScoreFormat::POINT_10_DECIMAL: return "POINT_10_DECIMAL";
80 default:
81 case Anime::ScoreFormat::POINT_100: return "POINT_100";
82 }
83 }
84
74 Anime::ListStatus ToListStatus(const std::string& str) { 85 Anime::ListStatus ToListStatus(const std::string& str) {
75 const std::unordered_map<std::string, Anime::ListStatus> map = { 86 const std::unordered_map<std::string, Anime::ListStatus> map = {
76 {"Currently watching", Anime::ListStatus::CURRENT}, 87 {"Currently watching", Anime::ListStatus::CURRENT},
77 {"Plan to watch", Anime::ListStatus::PLANNING}, 88 {"Plan to watch", Anime::ListStatus::PLANNING},
78 {"Completed", Anime::ListStatus::COMPLETED}, 89 {"Completed", Anime::ListStatus::COMPLETED},
148 if (map.find(str) == map.end()) 159 if (map.find(str) == map.end())
149 return Anime::TitleLanguage::ROMAJI; 160 return Anime::TitleLanguage::ROMAJI;
150 return map.at(str); 161 return map.at(str);
151 } 162 }
152 163
164 Anime::ScoreFormat ToScoreFormat(const std::string& str) {
165 const std::unordered_map<std::string, Anime::ScoreFormat> map = {
166 {"POINT_3", Anime::ScoreFormat::POINT_3},
167 {"POINT_5", Anime::ScoreFormat::POINT_5},
168 {"POINT_10", Anime::ScoreFormat::POINT_10},
169 {"POINT_10_DECIMAL", Anime::ScoreFormat::POINT_10_DECIMAL},
170 {"POINT_100", Anime::ScoreFormat::POINT_100}
171 };
172
173 if (map.find(str) == map.end())
174 return Anime::ScoreFormat::POINT_100;
175 return map.at(str);
176 }
177
153 /* Localized versions of ToString() functions */ 178 /* Localized versions of ToString() functions */
154 179
155 std::string ToLocalString(const Anime::ListStatus status) { 180 std::string ToLocalString(const Anime::ListStatus status) {
156 switch (status) { 181 switch (status) {
157 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching")); 182 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching"));