Skip to content

Commit

Permalink
Translate all Cancel buttons, fix translations for ETA
Browse files Browse the repository at this point in the history
Not all buttons with wxID_CANCEL was translateable. Moved some static strings like `/s` to translation files. Split `eta_format` info three, for each possible value (h:m:s, m:s, s).
  • Loading branch information
vktr committed Oct 19, 2020
2 parents 41af2bd + 555cbf0 commit 15824a3
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 19 deletions.
6 changes: 5 additions & 1 deletion lang/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,5 +283,9 @@
"labels": "Labels",
"label_details": "Label details",
"color": "Color",
"apply_filter": "Apply filter"
"apply_filter": "Apply filter",
"eta_hms_format": "{0}h {1}m {2}s",
"eta_ms_format": "{0}m {1}s",
"eta_s_format": "{0}s",
"per_second_format": "{0}/s"
}
2 changes: 1 addition & 1 deletion src/picotorrent/ui/dialogs/addmagnetlinkdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ AddMagnetLinkDialog::AddMagnetLinkDialog(wxWindow* parent, wxWindowID id)
ok->SetDefault();

buttonsSizer->Add(ok);
buttonsSizer->Add(new wxButton(this, wxID_CANCEL), 0, wxLEFT, FromDIP(7));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL, i18n("cancel")), 0, wxLEFT, FromDIP(7));

auto mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->AddSpacer(FromDIP(11));
Expand Down
4 changes: 2 additions & 2 deletions src/picotorrent/ui/dialogs/addtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ AddTorrentDialog::AddTorrentDialog(wxWindow* parent, wxWindowID id, std::vector<
m_filesModel->DecRef();

auto buttonsSizer = new wxBoxSizer(wxHORIZONTAL);
wxButton* ok = new wxButton(this, wxID_OK);
wxButton* ok = new wxButton(this, wxID_OK, i18n("ok"));
ok->SetDefault();

buttonsSizer->Add(ok);
buttonsSizer->AddSpacer(FromDIP(7));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL, i18n("cancel")));

auto mainSizer = new wxBoxSizer(wxVERTICAL);
mainSizer->Add(fileSizer, 0, wxEXPAND | wxALL, FromDIP(11));
Expand Down
4 changes: 2 additions & 2 deletions src/picotorrent/ui/dialogs/addtrackerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ AddTrackerDialog::AddTrackerDialog(wxWindow* parent, wxWindowID id)
m_url(new wxTextCtrl(this, wxID_ANY))
{
auto buttonsSizer = new wxBoxSizer(wxHORIZONTAL);
wxButton* ok = new wxButton(this, wxID_OK);
wxButton* ok = new wxButton(this, wxID_OK, i18n("cancel"));
ok->SetDefault();

buttonsSizer->Add(ok);
buttonsSizer->Add(new wxButton(this, wxID_CANCEL), 0, wxLEFT, FromDIP(7));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL, i18n("cancel")), 0, wxLEFT, FromDIP(7));

auto formSizer = new wxFlexGridSizer(2, FromDIP(7), FromDIP(10));
formSizer->AddGrowableCol(1, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/picotorrent/ui/dialogs/createtorrentdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ CreateTorrentDialog::CreateTorrentDialog(wxWindow* parent, wxWindowID id, Sessio
buttonsSizer->AddStretchSpacer();
buttonsSizer->Add(m_create);
buttonsSizer->AddSpacer(FromDIP(7));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL));
buttonsSizer->Add(new wxButton(this, wxID_CANCEL, i18n("cancel")));

auto sizer = new wxBoxSizer(wxVERTICAL);
sizer->Add(pathSizer, 0, wxEXPAND | wxALL, FromDIP(11));
Expand Down
11 changes: 8 additions & 3 deletions src/picotorrent/ui/models/peerlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include <fmt/format.h>
#include <libtorrent/peer_info.hpp>

#include "../../core//utils.hpp"
#include "../../core/utils.hpp"
#include "../translator.hpp"

namespace lt = libtorrent;
using pt::UI::Models::PeerListModel;
Expand Down Expand Up @@ -183,7 +184,9 @@ void PeerListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned
}
else
{
variant = fmt::format(L"{0}/s", Utils::toHumanFileSize(peer.payload_down_speed));
variant = fmt::format(
i18n("per_second_format"),
Utils::toHumanFileSize(peer.payload_down_speed));
}

break;
Expand All @@ -196,7 +199,9 @@ void PeerListModel::GetValueByRow(wxVariant &variant, unsigned int row, unsigned
}
else
{
variant = fmt::format(L"{0}/s", Utils::toHumanFileSize(peer.payload_up_speed));
variant = fmt::format(
i18n("per_second_format"),
Utils::toHumanFileSize(peer.payload_up_speed));
}

break;
Expand Down
14 changes: 9 additions & 5 deletions src/picotorrent/ui/models/torrentlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,16 +377,16 @@ void TorrentListModel::GetValueByRow(wxVariant& variant, uint32_t row, uint32_t
{
if (min_left.count() <= 0)
{
variant = fmt::format("{0}s", sec_left.count());
variant = fmt::format(i18n("eta_s_format"), sec_left.count());
break;
}

variant = fmt::format("{0}m {1}s", min_left.count(), sec_left.count());
variant = fmt::format(i18n("eta_ms_format"), min_left.count(), sec_left.count());
break;
}

variant = fmt::format(
"{0}h {1}m {2}s",
i18n("eta_hms_format"),
hours_left.count(),
min_left.count(),
sec_left.count());
Expand All @@ -402,7 +402,9 @@ void TorrentListModel::GetValueByRow(wxVariant& variant, uint32_t row, uint32_t
break;
}

variant = fmt::format(L"{0}/s", Utils::toHumanFileSize(status.downloadPayloadRate));
variant = fmt::format(
i18n("per_second_format"),
Utils::toHumanFileSize(status.downloadPayloadRate));

break;
}
Expand All @@ -415,7 +417,9 @@ void TorrentListModel::GetValueByRow(wxVariant& variant, uint32_t row, uint32_t
break;
}

variant = fmt::format(L"{0}/s", Utils::toHumanFileSize(status.uploadPayloadRate));
variant = fmt::format(
i18n("per_second_format"),
Utils::toHumanFileSize(status.uploadPayloadRate));

break;
}
Expand Down
14 changes: 13 additions & 1 deletion src/picotorrent/ui/models/trackerlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,20 @@ void TrackerListModel::GetValue(wxVariant& variant, const wxDataViewItem& item,
std::chrono::minutes min_left = std::chrono::duration_cast<std::chrono::minutes>(li->nextAnnounce - hours_left);
std::chrono::seconds sec_left = std::chrono::duration_cast<std::chrono::seconds>(li->nextAnnounce - hours_left - min_left);

if (hours_left.count() <= 0)
{
if (min_left.count() <= 0)
{
variant = fmt::format(i18n("eta_s_format"), sec_left.count());
break;
}

variant = fmt::format(i18n("eta_ms_format"), min_left.count(), sec_left.count());
break;
}

variant = fmt::format(
i18n("eta_format"),
i18n("eta_hms_format"),
hours_left.count(),
min_left.count(),
sec_left.count());
Expand Down
11 changes: 8 additions & 3 deletions src/picotorrent/ui/torrentdetailsoverviewpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ std::wstring SecondsToFriendly(std::chrono::seconds secs)
{
if (min_left.count() <= 0)
{
return fmt::format(L"{0}s", sec_left.count());
return fmt::format(
i18n("eta_s_format"),
sec_left.count());
}

return fmt::format(L"{0}m {1}s", min_left.count(), sec_left.count());
return fmt::format(
i18n("eta_ms_format"),
min_left.count(),
sec_left.count());
}

return fmt::format(
L"{0}h {1}m {2}s",
i18n("eta_hms_format"),
hours_left.count(),
min_left.count(),
sec_left.count());
Expand Down

0 comments on commit 15824a3

Please sign in to comment.