Mercurial > minori
annotate src/gui/translate/anime.cc @ 112:80f49f623d30
locale: allow switching locales without restarting
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 06 Nov 2023 13:41:30 -0500 |
parents | c4bb49c2f6eb |
children | f88eda79c60a |
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" |
51 | 4 #include <QCoreApplication> |
10 | 5 |
6 namespace Translate { | |
7 | |
15 | 8 std::string ToString(const Anime::ListStatus status) { |
10 | 9 switch (status) { |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
10 case Anime::ListStatus::CURRENT: return Strings::ToUtf8String(QCoreApplication::tr("Currently watching")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
11 case Anime::ListStatus::PLANNING: return Strings::ToUtf8String(QCoreApplication::tr("Plan to watch")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
12 case Anime::ListStatus::COMPLETED: return Strings::ToUtf8String(QCoreApplication::tr("Completed")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
13 case Anime::ListStatus::DROPPED: return Strings::ToUtf8String(QCoreApplication::tr("Dropped")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
14 case Anime::ListStatus::PAUSED: return Strings::ToUtf8String(QCoreApplication::tr("On hold")); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
15 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
16 case Anime::ListStatus::NOT_IN_LIST: return Strings::ToUtf8String(QCoreApplication::tr("Not in list")); |
10 | 17 } |
18 } | |
19 | |
15 | 20 std::string ToString(const Anime::SeriesFormat format) { |
10 | 21 switch (format) { |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
22 case Anime::SeriesFormat::TV: return Strings::ToUtf8String(QCoreApplication::tr("TV")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
23 case Anime::SeriesFormat::TV_SHORT: return Strings::ToUtf8String(QCoreApplication::tr("TV short")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
24 case Anime::SeriesFormat::OVA: return Strings::ToUtf8String(QCoreApplication::tr("OVA")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
25 case Anime::SeriesFormat::MOVIE: return Strings::ToUtf8String(QCoreApplication::tr("Movie")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
26 case Anime::SeriesFormat::SPECIAL: return Strings::ToUtf8String(QCoreApplication::tr("Special")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
27 case Anime::SeriesFormat::ONA: return Strings::ToUtf8String(QCoreApplication::tr("ONA")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
28 case Anime::SeriesFormat::MUSIC: return Strings::ToUtf8String(QCoreApplication::tr("Music")); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
29 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
30 case Anime::SeriesFormat::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); |
10 | 31 } |
32 } | |
33 | |
15 | 34 std::string ToString(const Anime::SeriesSeason season) { |
10 | 35 switch (season) { |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
36 case Anime::SeriesSeason::WINTER: return Strings::ToUtf8String(QCoreApplication::tr("Winter")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
37 case Anime::SeriesSeason::SUMMER: return Strings::ToUtf8String(QCoreApplication::tr("Summer")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
38 case Anime::SeriesSeason::FALL: return Strings::ToUtf8String(QCoreApplication::tr("Fall")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
39 case Anime::SeriesSeason::SPRING: return Strings::ToUtf8String(QCoreApplication::tr("Spring")); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
40 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
41 case Anime::SeriesSeason::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); |
10 | 42 } |
43 } | |
44 | |
15 | 45 std::string ToString(const Anime::SeriesStatus status) { |
10 | 46 switch (status) { |
65
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
47 case Anime::SeriesStatus::RELEASING: return Strings::ToUtf8String(QCoreApplication::tr("Currently airing")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
48 case Anime::SeriesStatus::FINISHED: return Strings::ToUtf8String(QCoreApplication::tr("Finished airing")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
49 case Anime::SeriesStatus::NOT_YET_RELEASED: return Strings::ToUtf8String(QCoreApplication::tr("Not yet aired")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
50 case Anime::SeriesStatus::CANCELLED: return Strings::ToUtf8String(QCoreApplication::tr("Cancelled")); |
26721c28bf22
*: avoid usage of (to|from)StdString
Paper <mrpapersonic@gmail.com>
parents:
51
diff
changeset
|
51 case Anime::SeriesStatus::HIATUS: return Strings::ToUtf8String(QCoreApplication::tr("On hiatus")); |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
52 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
53 case Anime::SeriesStatus::UNKNOWN: return Strings::ToUtf8String(QCoreApplication::tr("Unknown")); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
54 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
55 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
56 |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
57 std::string ToString(const Anime::Services service) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
58 switch (service) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
59 case Anime::Services::ANILIST: return Strings::ToUtf8String(QCoreApplication::tr("AniList")); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
60 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
61 case Anime::Services::NONE: return Strings::ToUtf8String(QCoreApplication::tr("None")); |
10 | 62 } |
63 } | |
64 | |
90
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
65 Anime::Services ToService(const std::string& str) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
66 const std::unordered_map<std::string, Anime::Services> map = { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
67 {"None", Anime::Services::NONE }, |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
68 {"AniList", Anime::Services::ANILIST} |
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 if (map.find(str) == map.end()) |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
72 return Anime::Services::NONE; |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
73 return map.at(str); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
74 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
75 |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
76 std::string ToString(const Anime::TitleLanguage language) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
77 switch (language) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
78 case Anime::TitleLanguage::NATIVE: return Strings::ToUtf8String(QCoreApplication::tr("Native")); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
79 case Anime::TitleLanguage::ENGLISH: return Strings::ToUtf8String(QCoreApplication::tr("English")); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
80 default: |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
81 case Anime::TitleLanguage::ROMAJI: return Strings::ToUtf8String(QCoreApplication::tr("Romaji")); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
82 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
83 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
84 |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
85 Anime::TitleLanguage ToLanguage(const std::string& str) { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
86 const std::unordered_map<std::string, Anime::TitleLanguage> map = { |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
87 {"Romaji", Anime::TitleLanguage::ROMAJI}, |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
88 {"Native", Anime::TitleLanguage::NATIVE}, |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
89 {"English", Anime::TitleLanguage::ENGLISH} |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
90 }; |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
91 |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
92 if (map.find(str) == map.end()) |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
93 return Anime::TitleLanguage::ROMAJI; |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
94 return map.at(str); |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
95 } |
c4bb49c2f6eb
config: improve handling of vars
Paper <mrpapersonic@gmail.com>
parents:
81
diff
changeset
|
96 |
46 | 97 } // namespace Translate |