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