Mercurial > minori
comparison src/services/services.cc @ 334:948955c3ba81
services: use fmt for setting the status bar
this should make localization easier
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Mon, 17 Jun 2024 20:35:31 -0400 |
parents | b5d6c27c308f |
children |
comparison
equal
deleted
inserted
replaced
333:5980a960f3e1 | 334:948955c3ba81 |
---|---|
1 #include "services/services.h" | 1 #include "services/services.h" |
2 #include "core/session.h" | 2 #include "core/session.h" |
3 #include "core/strings.h" | |
3 #include "gui/translate/anime.h" | 4 #include "gui/translate/anime.h" |
4 #include "services/anilist.h" | 5 #include "services/anilist.h" |
5 #include "services/kitsu.h" | 6 #include "services/kitsu.h" |
6 | 7 |
8 #include <fmt/core.h> | |
9 | |
7 namespace Services { | 10 namespace Services { |
8 | 11 |
9 void Synchronize() { | 12 void Synchronize() { |
10 session.SetStatusBar(Translate::ToString(session.config.service) + ": Retrieving anime list..."); | 13 session.SetStatusBar(fmt::format(Strings::Translate("{}: Retrieving anime list..."), Translate::ToString(session.config.service))); |
11 | 14 |
12 switch (session.config.service) { | 15 switch (session.config.service) { |
13 case Anime::Service::AniList: AniList::GetAnimeList(); break; | 16 case Anime::Service::AniList: AniList::GetAnimeList(); break; |
14 case Anime::Service::Kitsu: Kitsu::GetAnimeList(); break; | 17 case Anime::Service::Kitsu: Kitsu::GetAnimeList(); break; |
15 default: break; | 18 default: break; |
22 default: return false; | 25 default: return false; |
23 } | 26 } |
24 } | 27 } |
25 | 28 |
26 std::vector<int> Search(const std::string& search) { | 29 std::vector<int> Search(const std::string& search) { |
27 session.SetStatusBar(Translate::ToString(session.config.service) + ": Requesting search query..."); | 30 session.SetStatusBar(fmt::format(Strings::Translate("{}: Requesting search query..."), Translate::ToString(session.config.service))); |
28 | 31 |
29 switch (session.config.service) { | 32 switch (session.config.service) { |
30 case Anime::Service::AniList: return AniList::Search(search); | 33 case Anime::Service::AniList: return AniList::Search(search); |
31 case Anime::Service::Kitsu: return Kitsu::Search(search); | 34 case Anime::Service::Kitsu: return Kitsu::Search(search); |
32 default: return {}; | 35 default: return {}; |
33 } | 36 } |
34 } | 37 } |
35 | 38 |
36 bool GetSeason(Anime::Season season) { | 39 bool GetSeason(Anime::Season season) { |
37 session.SetStatusBar(Translate::ToString(session.config.service) + ": Retrieving anime season data..."); | 40 session.SetStatusBar(fmt::format(Strings::Translate("{}: Retrieving anime season data..."), Translate::ToString(session.config.service))); |
38 | 41 |
39 switch (session.config.service) { | 42 switch (session.config.service) { |
40 case Anime::Service::AniList: return AniList::GetSeason(season); | 43 case Anime::Service::AniList: return AniList::GetSeason(season); |
41 case Anime::Service::Kitsu: return Kitsu::GetSeason(season); | 44 case Anime::Service::Kitsu: return Kitsu::GetSeason(season); |
42 default: return {}; | 45 default: return {}; |
43 } | 46 } |
44 } | 47 } |
45 | 48 |
46 void UpdateAnimeEntry(int id) { | 49 void UpdateAnimeEntry(int id) { |
47 session.SetStatusBar(Translate::ToString(session.config.service) + ": Updating remote anime entry..."); | 50 session.SetStatusBar(fmt::format(Strings::Translate("{}: Updating remote anime entry..."), Translate::ToString(session.config.service))); |
48 | 51 |
49 switch (session.config.service) { | 52 switch (session.config.service) { |
50 case Anime::Service::AniList: AniList::UpdateAnimeEntry(id); break; | 53 case Anime::Service::AniList: AniList::UpdateAnimeEntry(id); break; |
51 case Anime::Service::Kitsu: Kitsu::UpdateAnimeEntry(id); break; | 54 case Anime::Service::Kitsu: Kitsu::UpdateAnimeEntry(id); break; |
52 default: break; | 55 default: break; |