annotate src/gui/translate/anilist.cc @ 322:c32467cd06bb

core/strings: add Strings::Translate function as tr() -> ToUtf8String
author Paper <paper@paper.us.eu.org>
date Wed, 12 Jun 2024 22:15:53 -0400
parents 2115488eb302
children b5d6c27c308f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
301
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
1 #include "gui/translate/anilist.h"
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
2 #include <unordered_map>
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
3
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
4 namespace Translate {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
5 namespace AniList {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
6
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
7 Anime::SeriesStatus ToSeriesStatus(const std::string& status) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
8 static const std::unordered_map<std::string, Anime::SeriesStatus> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
9 {"FINISHED", Anime::SeriesStatus::Finished },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
10 {"RELEASING", Anime::SeriesStatus::Releasing },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
11 {"NOT_YET_RELEASED", Anime::SeriesStatus::NotYetReleased},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
12 {"CANCELLED", Anime::SeriesStatus::Cancelled },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
13 {"HIATUS", Anime::SeriesStatus::Hiatus }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
14 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
15
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
16 if (map.find(status) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
17 return Anime::SeriesStatus::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
18 return map.at(status);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
19 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
20
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
21 Anime::SeriesSeason ToSeriesSeason(const std::string& season) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
23 {"WINTER", Anime::SeriesSeason::Winter},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
24 {"SPRING", Anime::SeriesSeason::Spring},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
25 {"SUMMER", Anime::SeriesSeason::Summer},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
26 {"FALL", Anime::SeriesSeason::Fall }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
27 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
28
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
29 if (map.find(season) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
30 return Anime::SeriesSeason::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
31 return map.at(season);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
32 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
33
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = {
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
36 {"TV", Anime::SeriesFormat::Tv },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
37 {"TV_SHORT", Anime::SeriesFormat::TvShort},
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
38 {"MOVIE", Anime::SeriesFormat::Movie },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
39 {"SPECIAL", Anime::SeriesFormat::Special },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
40 {"OVA", Anime::SeriesFormat::Ova },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
41 {"ONA", Anime::SeriesFormat::Ona },
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
42 {"MUSIC", Anime::SeriesFormat::Music }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
43 };
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
44
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
45 if (map.find(format) == map.end())
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
46 return Anime::SeriesFormat::Unknown;
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
47 return map.at(format);
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
48 }
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
49
304
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
50 std::string ToString(Anime::SeriesSeason season) {
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
51 switch (season) {
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
52 default:
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
53 case Anime::SeriesSeason::Winter: return "WINTER";
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
54 case Anime::SeriesSeason::Fall: return "FALL";
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
55 case Anime::SeriesSeason::Summer: return "SUMMER";
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
56 case Anime::SeriesSeason::Spring: return "SPRING";
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
57 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
58 }
2115488eb302 *: add very early season searcher
Paper <paper@paper.us.eu.org>
parents: 301
diff changeset
59
301
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
60 } // namespace AniList
b1f625b0227c *: convert all files CRLF -> LF
Paper <paper@paper.us.eu.org>
parents: 279
diff changeset
61 } // namespace Translate