Mercurial > minori
comparison src/gui/translate/anilist.cc @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 2115488eb302 |
children |
comparison
equal
deleted
inserted
replaced
326:10096c5489e3 | 327:b5d6c27c308f |
---|---|
16 if (map.find(status) == map.end()) | 16 if (map.find(status) == map.end()) |
17 return Anime::SeriesStatus::Unknown; | 17 return Anime::SeriesStatus::Unknown; |
18 return map.at(status); | 18 return map.at(status); |
19 } | 19 } |
20 | 20 |
21 Anime::SeriesSeason ToSeriesSeason(const std::string& season) { | 21 Anime::Season::Name ToSeriesSeason(const std::string& season) { |
22 static const std::unordered_map<std::string, Anime::SeriesSeason> map = { | 22 static const std::unordered_map<std::string, Anime::Season::Name> map = { |
23 {"WINTER", Anime::SeriesSeason::Winter}, | 23 {"WINTER", Anime::Season::Name::Winter}, |
24 {"SPRING", Anime::SeriesSeason::Spring}, | 24 {"SPRING", Anime::Season::Name::Spring}, |
25 {"SUMMER", Anime::SeriesSeason::Summer}, | 25 {"SUMMER", Anime::Season::Name::Summer}, |
26 {"FALL", Anime::SeriesSeason::Fall } | 26 {"FALL", Anime::Season::Name::Autumn} |
27 }; | 27 }; |
28 | 28 |
29 if (map.find(season) == map.end()) | 29 if (map.find(season) == map.end()) |
30 return Anime::SeriesSeason::Unknown; | 30 return Anime::Season::Name::Unknown; |
31 return map.at(season); | 31 return map.at(season); |
32 } | 32 } |
33 | 33 |
34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) { | 34 Anime::SeriesFormat ToSeriesFormat(const std::string& format) { |
35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { | 35 static const std::unordered_map<std::string, enum Anime::SeriesFormat> map = { |
45 if (map.find(format) == map.end()) | 45 if (map.find(format) == map.end()) |
46 return Anime::SeriesFormat::Unknown; | 46 return Anime::SeriesFormat::Unknown; |
47 return map.at(format); | 47 return map.at(format); |
48 } | 48 } |
49 | 49 |
50 std::string ToString(Anime::SeriesSeason season) { | 50 std::string ToString(Anime::Season::Name season) { |
51 switch (season) { | 51 switch (season) { |
52 default: | 52 default: |
53 case Anime::SeriesSeason::Winter: return "WINTER"; | 53 case Anime::Season::Name::Winter: return "WINTER"; |
54 case Anime::SeriesSeason::Fall: return "FALL"; | 54 case Anime::Season::Name::Autumn: return "FALL"; |
55 case Anime::SeriesSeason::Summer: return "SUMMER"; | 55 case Anime::Season::Name::Summer: return "SUMMER"; |
56 case Anime::SeriesSeason::Spring: return "SPRING"; | 56 case Anime::Season::Name::Spring: return "SPRING"; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 } // namespace AniList | 60 } // namespace AniList |
61 } // namespace Translate | 61 } // namespace Translate |