Mercurial > minori
annotate src/gui/translate/anime.cc @ 331:3c755136f074
CI: update for new repository URL
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 17 Jun 2024 18:30:54 -0400 |
parents | b5d6c27c308f |
children | 5980a960f3e1 |
rev | line source |
---|---|
10 | 1 #include "core/anime.h" |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
2 #include "core/strings.h" |
15 | 3 #include "gui/translate/anime.h" |
202 | 4 |
51 | 5 #include <QCoreApplication> |
10 | 6 |
202 | 7 #include <unordered_map> |
8 | |
10 | 9 namespace Translate { |
10 | |
15 | 11 std::string ToString(const Anime::ListStatus status) { |
10 | 12 switch (status) { |
279 | 13 case Anime::ListStatus::Current: return "Currently watching"; |
14 case Anime::ListStatus::Planning: return "Plan to watch"; | |
15 case Anime::ListStatus::Completed: return "Completed"; | |
16 case Anime::ListStatus::Dropped: return "Dropped"; | |
17 case Anime::ListStatus::Paused: return "On hold"; | |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
18 default: |
279 | 19 case Anime::ListStatus::NotInList: return "Not in list"; |
10 | 20 } |
21 } | |
22 | |
15 | 23 std::string ToString(const Anime::SeriesFormat format) { |
10 | 24 switch (format) { |
279 | 25 case Anime::SeriesFormat::Tv: return "TV"; |
26 case Anime::SeriesFormat::TvShort: return "TV short"; | |
27 case Anime::SeriesFormat::Ova: return "OVA"; | |
28 case Anime::SeriesFormat::Movie: return "Movie"; | |
29 case Anime::SeriesFormat::Special: return "Special"; | |
30 case Anime::SeriesFormat::Ona: return "ONA"; | |
31 case Anime::SeriesFormat::Music: return "Music"; | |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
32 default: |
279 | 33 case Anime::SeriesFormat::Unknown: return "Unknown"; |
10 | 34 } |
35 } | |
36 | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
37 std::string ToString(const Anime::Season::Name season) { |
10 | 38 switch (season) { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
39 case Anime::Season::Name::Winter: return "Winter"; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
40 case Anime::Season::Name::Summer: return "Summer"; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
41 case Anime::Season::Name::Autumn: return "Autumn"; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
42 case Anime::Season::Name::Spring: return "Spring"; |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
43 default: |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
44 case Anime::Season::Name::Unknown: return "Unknown"; |
10 | 45 } |
46 } | |
47 | |
15 | 48 std::string ToString(const Anime::SeriesStatus status) { |
10 | 49 switch (status) { |
279 | 50 case Anime::SeriesStatus::Releasing: return "Currently airing"; |
51 case Anime::SeriesStatus::Finished: return "Finished airing"; | |
52 case Anime::SeriesStatus::NotYetReleased: return "Not yet aired"; | |
53 case Anime::SeriesStatus::Cancelled: return "Cancelled"; | |
54 case Anime::SeriesStatus::Hiatus: return "On hiatus"; | |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
55 default: |
279 | 56 case Anime::SeriesStatus::Unknown: return "Unknown"; |
175 | 57 } |
58 } | |
59 | |
279 | 60 std::string ToString(const Anime::Service service) { |
175 | 61 switch (service) { |
279 | 62 case Anime::Service::AniList: return "AniList"; |
286
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
279
diff
changeset
|
63 case Anime::Service::MyAnimeList: return "MyAnimeList"; |
53e3c015a973
anime: initial cross-service support
Paper <paper@paper.us.eu.org>
parents:
279
diff
changeset
|
64 case Anime::Service::Kitsu: return "Kitsu"; |
175 | 65 default: |
279 | 66 case Anime::Service::None: return "None"; |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
67 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
68 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
69 |
175 | 70 std::string ToString(const Anime::TitleLanguage language) { |
71 switch (language) { | |
279 | 72 case Anime::TitleLanguage::Native: return "Native"; |
73 case Anime::TitleLanguage::English: return "English"; | |
175 | 74 default: |
279 | 75 case Anime::TitleLanguage::Romaji: return "Romaji"; |
175 | 76 } |
77 } | |
78 | |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
79 std::string ToString(const Anime::ScoreFormat format) { |
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
80 switch (format) { |
279 | 81 case Anime::ScoreFormat::Point3: return "3-point"; |
82 case Anime::ScoreFormat::Point5: return "5-point"; | |
83 case Anime::ScoreFormat::Point10: return "10-point"; | |
84 case Anime::ScoreFormat::Point10Decimal: return "10-point Decimal"; | |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
85 default: |
279 | 86 case Anime::ScoreFormat::Point100: return "100-point"; |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
87 } |
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
88 } |
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
89 |
175 | 90 Anime::ListStatus ToListStatus(const std::string& str) { |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
91 static const std::unordered_map<std::string, Anime::ListStatus> map = { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
92 {"currently watching", Anime::ListStatus::Current }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
93 {"plan to watch", Anime::ListStatus::Planning }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
94 {"completed", Anime::ListStatus::Completed}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
95 {"dropped", Anime::ListStatus::Dropped }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
96 {"on hold", Anime::ListStatus::Paused } |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
97 }; |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
98 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
99 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
100 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
101 if (map.find(lower) == map.end()) |
279 | 102 return Anime::ListStatus::NotInList; |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
103 return map.at(lower); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
104 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
105 |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
106 Anime::SeriesStatus ToSeriesStatus(const std::string& str) { |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
107 static const std::unordered_map<std::string, Anime::SeriesStatus> map = { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
108 {"currently airing", Anime::SeriesStatus::Releasing }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
109 {"finished airing", Anime::SeriesStatus::Finished }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
110 {"not yet aired", Anime::SeriesStatus::NotYetReleased}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
111 {"cancelled", Anime::SeriesStatus::Cancelled }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
112 {"on hiatus", Anime::SeriesStatus::Hiatus } |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
113 }; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
114 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
115 std::string lower = Strings::ToLower(str); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
116 |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
117 if (map.find(str) == map.end()) |
279 | 118 return Anime::SeriesStatus::Unknown; |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
119 return map.at(str); |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
120 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
121 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
122 Anime::Season::Name ToSeriesSeason(const std::string& str) { |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
123 static const std::unordered_map<std::string, Anime::Season::Name> map = { |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
124 {"winter", Anime::Season::Name::Winter}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
125 {"summer", Anime::Season::Name::Summer}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
126 {"fall", Anime::Season::Name::Autumn}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
127 {"autumn", Anime::Season::Name::Autumn}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
128 {"spring", Anime::Season::Name::Spring}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
129 }; |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
130 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
131 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
132 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
133 if (map.find(lower) == map.end()) |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
134 return Anime::Season::Name::Unknown; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
135 return map.at(lower); |
10 | 136 } |
137 | |
175 | 138 Anime::SeriesFormat ToSeriesFormat(const std::string& str) { |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
139 static const std::unordered_map<std::string, Anime::SeriesFormat> map = { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
140 {"tv", Anime::SeriesFormat::Tv }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
141 {"tv short", Anime::SeriesFormat::TvShort}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
142 {"ova", Anime::SeriesFormat::Ova }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
143 {"movie", Anime::SeriesFormat::Movie }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
144 {"special", Anime::SeriesFormat::Special }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
145 {"ona", Anime::SeriesFormat::Ona }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
146 {"music", Anime::SeriesFormat::Music } |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
147 }; |
175 | 148 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
149 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
150 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
151 if (map.find(lower) == map.end()) |
279 | 152 return Anime::SeriesFormat::Unknown; |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
153 return map.at(lower); |
175 | 154 } |
155 | |
279 | 156 Anime::Service ToService(const std::string& str) { |
157 static const std::unordered_map<std::string, Anime::Service> map = { | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
158 {"anilist", Anime::Service::AniList}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
159 {"myanimelist", Anime::Service::MyAnimeList}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
160 {"kitsu", Anime::Service::Kitsu} |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
161 }; |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
162 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
163 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
164 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
165 if (map.find(lower) == map.end()) |
279 | 166 return Anime::Service::None; |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
167 return map.at(lower); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
168 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
169 |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
170 Anime::TitleLanguage ToLanguage(const std::string& str) { |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
171 static const std::unordered_map<std::string, Anime::TitleLanguage> map = { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
172 {"romaji", Anime::TitleLanguage::Romaji }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
173 {"native", Anime::TitleLanguage::Native }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
174 {"english", Anime::TitleLanguage::English} |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
175 }; |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
176 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
177 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
178 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
179 if (map.find(lower) == map.end()) |
279 | 180 return Anime::TitleLanguage::Romaji; |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
181 return map.at(lower); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
182 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
183 |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
184 Anime::ScoreFormat ToScoreFormat(const std::string& str) { |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
185 static const std::unordered_map<std::string, Anime::ScoreFormat> map = { |
279 | 186 {"3-point", Anime::ScoreFormat::Point3}, |
187 {"5-point", Anime::ScoreFormat::Point5}, | |
188 {"10-point", Anime::ScoreFormat::Point10 }, | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
189 {"10-point decimal", Anime::ScoreFormat::Point10Decimal}, |
279 | 190 {"100-point", Anime::ScoreFormat::Point100 }, |
191 /* old values, provided for compatibility */ | |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
192 {"point_3", Anime::ScoreFormat::Point3 }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
193 {"point_5", Anime::ScoreFormat::Point5 }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
194 {"point_10", Anime::ScoreFormat::Point10 }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
195 {"point_10_decimal", Anime::ScoreFormat::Point10Decimal}, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
196 {"point_100", Anime::ScoreFormat::Point100 }, |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
197 }; |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
198 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
199 std::string lower = Strings::ToLower(str); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
200 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
201 if (map.find(lower) == map.end()) |
279 | 202 return Anime::ScoreFormat::Point100; |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
203 return map.at(lower); |
185
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
204 } |
62e336597bb7
anime list: add support for different score formats
Paper <mrpapersonic@gmail.com>
parents:
175
diff
changeset
|
205 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
206 /* Localized versions of ToString() functions. Meant for display to the user. */ |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
207 |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
208 std::string ToLocalString(const Anime::ListStatus status) { |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
209 switch (status) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
210 case Anime::ListStatus::Current: return Strings::Translate("Currently watching"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
211 case Anime::ListStatus::Planning: return Strings::Translate("Plan to watch"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
212 case Anime::ListStatus::Completed: return Strings::Translate("Completed"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
213 case Anime::ListStatus::Dropped: return Strings::Translate("Dropped"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
214 case Anime::ListStatus::Paused: return Strings::Translate("On hold"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
215 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
216 case Anime::ListStatus::NotInList: return Strings::Translate("Not in list"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
217 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
218 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
219 |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
220 std::string ToLocalString(const Anime::SeriesFormat format) { |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
221 switch (format) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
222 case Anime::SeriesFormat::Tv: return Strings::Translate("TV"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
223 case Anime::SeriesFormat::TvShort: return Strings::Translate("TV short"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
224 case Anime::SeriesFormat::Ova: return Strings::Translate("OVA"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
225 case Anime::SeriesFormat::Movie: return Strings::Translate("Movie"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
226 case Anime::SeriesFormat::Special: return Strings::Translate("Special"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
227 case Anime::SeriesFormat::Ona: return Strings::Translate("ONA"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
228 case Anime::SeriesFormat::Music: return Strings::Translate("Music"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
229 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
230 case Anime::SeriesFormat::Unknown: return Strings::Translate("Unknown"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
231 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
232 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
233 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
234 std::string ToLocalString(const Anime::Season::Name season) { |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
235 switch (season) { |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
236 case Anime::Season::Name::Winter: return Strings::Translate("Winter"); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
237 case Anime::Season::Name::Summer: return Strings::Translate("Summer"); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
238 case Anime::Season::Name::Autumn: return Strings::Translate("Autumn"); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
239 case Anime::Season::Name::Spring: return Strings::Translate("Spring"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
240 default: |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
241 case Anime::Season::Name::Unknown: return Strings::Translate("Unknown"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
242 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
243 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
244 |
327
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
245 std::string ToLocalString(const Anime::Season& season) { |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
246 std::string year = (season.year) ? Strings::ToUtf8String(season.year) : Strings::Translate("Unknown"); |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
247 |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
248 return ToLocalString(season.season) + " " + year; |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
249 } |
b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents:
322
diff
changeset
|
250 |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
251 std::string ToLocalString(const Anime::SeriesStatus status) { |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
252 switch (status) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
253 case Anime::SeriesStatus::Releasing: return Strings::Translate("Currently airing"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
254 case Anime::SeriesStatus::Finished: return Strings::Translate("Finished airing"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
255 case Anime::SeriesStatus::NotYetReleased: return Strings::Translate("Not yet aired"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
256 case Anime::SeriesStatus::Cancelled: return Strings::Translate("Cancelled"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
257 case Anime::SeriesStatus::Hiatus: return Strings::Translate("On hiatus"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
258 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
259 case Anime::SeriesStatus::Unknown: return Strings::Translate("Unknown"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
260 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
261 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
262 |
279 | 263 std::string ToLocalString(const Anime::Service service) { |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
264 switch (service) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
265 case Anime::Service::AniList: return Strings::Translate("AniList"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
266 case Anime::Service::MyAnimeList: return Strings::Translate("MyAnimeList"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
267 case Anime::Service::Kitsu: return Strings::Translate("Kitsu"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
268 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
269 case Anime::Service::None: return Strings::Translate("None"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
270 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
271 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
272 |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
273 std::string ToLocalString(const Anime::TitleLanguage language) { |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
274 switch (language) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
275 case Anime::TitleLanguage::Native: return Strings::Translate("Native"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
276 case Anime::TitleLanguage::English: return Strings::Translate("English"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
277 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
278 case Anime::TitleLanguage::Romaji: return Strings::Translate("Romaji"); |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
279 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
280 } |
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
90
diff
changeset
|
281 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
282 std::string ToLocalString(const Anime::ScoreFormat format) { |
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
283 switch (format) { |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
284 case Anime::ScoreFormat::Point3: return Strings::Translate("3-point"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
285 case Anime::ScoreFormat::Point5: return Strings::Translate("5-point"); |
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
286 case Anime::ScoreFormat::Point10: return Strings::Translate("10-point"); |
279 | 287 case Anime::ScoreFormat::Point10Decimal: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
288 return Strings::Translate("10-point Decimal"); |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
289 default: |
322
c32467cd06bb
core/strings: add Strings::Translate function as tr() -> ToUtf8String
Paper <paper@paper.us.eu.org>
parents:
286
diff
changeset
|
290 case Anime::ScoreFormat::Point100: return Strings::Translate("100-point"); |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
291 } |
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
292 } |
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
185
diff
changeset
|
293 |
46 | 294 } // namespace Translate |