summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-12-26 00:22:12 +0100
committerCarl Hetherington <cth@carlh.net>2024-12-26 00:27:12 +0100
commitc87429313b25d102201a013e22e01dae8ba78b5b (patch)
treef8265c937f8297712f7ab3680f2b0ede81c94ddf
parent8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (diff)
Use fmt::format() instead of locale_convert<string>
In some places I just used to_string() as there seems no point in localising things like small ints.
-rw-r--r--src/lib/content.cc4
-rw-r--r--src/lib/transcode_job.cc4
-rw-r--r--src/lib/user_property.h11
-rw-r--r--src/lib/util.cc6
-rw-r--r--src/lib/writer.cc6
-rw-r--r--src/wx/content_advanced_dialog.cc3
-rw-r--r--src/wx/dcp_panel.cc2
-rw-r--r--src/wx/playhead_to_frame_dialog.cc6
-rw-r--r--src/wx/timer_display.cc9
-rw-r--r--src/wx/video_waveform_plot.cc2
-rw-r--r--src/wx/wx_util.cc12
11 files changed, 39 insertions, 26 deletions
diff --git a/src/lib/content.cc b/src/lib/content.cc
index 0abb061c8..125a6a3c2 100644
--- a/src/lib/content.cc
+++ b/src/lib/content.cc
@@ -493,7 +493,7 @@ Content::add_properties (shared_ptr<const Film>, list<UserProperty>& p) const
UserProperty (
UserProperty::VIDEO,
_("Frame rate"),
- locale_convert<string> (_video_frame_rate.get(), 5),
+ fmt::format("{:.5L}", _video_frame_rate.get()),
_("frames per second")
)
);
@@ -502,7 +502,7 @@ Content::add_properties (shared_ptr<const Film>, list<UserProperty>& p) const
UserProperty (
UserProperty::GENERAL,
_("Prepared for video frame rate"),
- locale_convert<string> (_video_frame_rate.get(), 5),
+ fmt::format("{:.5L}", _video_frame_rate.get()),
_("frames per second")
)
);
diff --git a/src/lib/transcode_job.cc b/src/lib/transcode_job.cc
index bdb0cb2b1..f25f34f9f 100644
--- a/src/lib/transcode_job.cc
+++ b/src/lib/transcode_job.cc
@@ -130,7 +130,7 @@ TranscodeJob::run ()
set_progress (1);
set_state (FINISHED_OK);
- LOG_GENERAL(N_("Transcode job completed successfully: {} fps"), dcp::locale_convert<string>(frames_per_second(), 2, true));
+ LOG_GENERAL(N_("Transcode job completed successfully: {:.2L} fps"), frames_per_second());
if (variant::count_created_dcps() && dynamic_pointer_cast<DCPFilmEncoder>(_encoder)) {
try {
@@ -179,7 +179,7 @@ TranscodeJob::status () const
auto status = fmt::format(_("{}; {}/{} frames"), Job::status(), _encoder->frames_done(), _film->length().frames_round(_film->video_frame_rate()));
if (auto const fps = _encoder->current_rate()) {
/// TRANSLATORS: fps here is an abbreviation for frames per second
- status += fmt::format(_("; {} fps"), dcp::locale_convert<string>(*fps, 1, true));
+ status += fmt::format(_("; {:.1L} fps"), *fps);
}
return status;
diff --git a/src/lib/user_property.h b/src/lib/user_property.h
index fb597eeb6..e7c9b843b 100644
--- a/src/lib/user_property.h
+++ b/src/lib/user_property.h
@@ -23,7 +23,7 @@
#define DCPOMATIC_USER_PROPERTY_H
-#include <dcp/locale_convert.h>
+#include <fmt/format.h>
class UserProperty
@@ -40,10 +40,17 @@ public:
UserProperty (Category category_, std::string key_, T value_, std::string unit_ = "")
: category (category_)
, key (key_)
- , value (dcp::locale_convert<std::string> (value_))
+ , value(fmt::format("{:L}", value_))
, unit (unit_)
{}
+ UserProperty(Category category_, std::string key_, std::string value_, std::string unit_ = "")
+ : category(category_)
+ , key(key_)
+ , value(value_)
+ , unit(unit_)
+ {}
+
Category category;
std::string key;
std::string value;
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 01f126559..24108f411 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -205,7 +205,7 @@ seconds_to_approximate_hms (int s)
if (hours) {
/// TRANSLATORS: h here is an abbreviation for hours
- ap += locale_convert<string>(h) + _("h");
+ ap += fmt::to_string(h) + _("h");
if (minutes || seconds) {
ap += N_(" ");
@@ -214,7 +214,7 @@ seconds_to_approximate_hms (int s)
if (minutes) {
/// TRANSLATORS: m here is an abbreviation for minutes
- ap += locale_convert<string>(m) + _("m");
+ ap += fmt::to_string(m) + _("m");
if (seconds) {
ap += N_(" ");
@@ -224,7 +224,7 @@ seconds_to_approximate_hms (int s)
if (seconds) {
/* Seconds */
/// TRANSLATORS: s here is an abbreviation for seconds
- ap += locale_convert<string>(s) + _("s");
+ ap += fmt::to_string(s) + _("s");
}
return ap;
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index 61785f558..df3eb79d4 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -766,10 +766,10 @@ Writer::write_cover_sheet()
}
}
- if (size > (1000000000L)) {
- boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}GB", dcp::locale_convert<string>(size / 1000000000.0, 1, true)));
+ if (size > 1000000000L) {
+ boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}GB", fmt::format("{:L}", size / 1000000000.0, 1, true)));
} else {
- boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}MB", dcp::locale_convert<string>(size / 1000000.0, 1, true)));
+ boost::algorithm::replace_all(text, "$SIZE", fmt::format("{}MB", fmt::format("{:L}", size / 1000000.0, 1, true)));
}
auto ch = audio_channel_types (film()->mapped_audio_channels(), film()->audio_channels());
diff --git a/src/wx/content_advanced_dialog.cc b/src/wx/content_advanced_dialog.cc
index d78adedea..b780ad970 100644
--- a/src/wx/content_advanced_dialog.cc
+++ b/src/wx/content_advanced_dialog.cc
@@ -32,6 +32,7 @@
#include "lib/ffmpeg_content.h"
#include "lib/image_content.h"
#include "lib/video_content.h"
+#include <dcp/locale_convert.h>
#include <dcp/warnings.h>
LIBDCP_DISABLE_WARNINGS
#include <wx/gbsizer.h>
@@ -129,7 +130,7 @@ ContentAdvancedDialog::ContentAdvancedDialog (wxWindow* parent, shared_ptr<Conte
auto vfr = _content->video_frame_rate ();
if (vfr) {
- _video_frame_rate->SetValue (std_to_wx(locale_convert<string>(*vfr)));
+ _video_frame_rate->SetValue(std_to_wx(fmt::format("{:L}", *vfr)));
}
_burnt_subtitle->SetValue (_content->video && static_cast<bool>(_content->video->burnt_subtitle_language()));
diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc
index 83f37c9de..bacad5c6e 100644
--- a/src/wx/dcp_panel.cc
+++ b/src/wx/dcp_panel.cc
@@ -437,7 +437,7 @@ DCPPanel::film_changed(FilmProperty p)
if (_film->audio_channels() < minimum_allowed_audio_channels()) {
_film->set_audio_channels (minimum_allowed_audio_channels());
} else {
- checked_set (_audio_channels, locale_convert<string>(max(minimum_allowed_audio_channels(), _film->audio_channels())));
+ checked_set(_audio_channels, fmt::to_string(max(minimum_allowed_audio_channels(), _film->audio_channels())));
setup_dcp_name ();
}
break;
diff --git a/src/wx/playhead_to_frame_dialog.cc b/src/wx/playhead_to_frame_dialog.cc
index e307fa6b1..ee338763f 100644
--- a/src/wx/playhead_to_frame_dialog.cc
+++ b/src/wx/playhead_to_frame_dialog.cc
@@ -18,13 +18,17 @@
*/
+
#include "playhead_to_frame_dialog.h"
+#include <fmt/format.h>
#include <dcp/locale_convert.h>
+
using std::string;
using dcp::locale_convert;
using namespace dcpomatic;
+
PlayheadToFrameDialog::PlayheadToFrameDialog (wxWindow* parent, DCPTime time, int fps)
: TableDialog (parent, _("Go to frame"), 2, 1, true)
, _fps (fps)
@@ -32,7 +36,7 @@ PlayheadToFrameDialog::PlayheadToFrameDialog (wxWindow* parent, DCPTime time, in
add (_("Go to"), true);
_frame = add(new wxTextCtrl(this, wxID_ANY, {}));
_frame->SetFocus ();
- _frame->SetValue (std_to_wx(locale_convert<string>(time.frames_round(fps) + 1)));
+ _frame->SetValue(std_to_wx(fmt::format("{:L}", time.frames_round(fps) + 1)));
_frame->SetSelection (-1, -1);
layout ();
diff --git a/src/wx/timer_display.cc b/src/wx/timer_display.cc
index 4dd9adf42..95469c273 100644
--- a/src/wx/timer_display.cc
+++ b/src/wx/timer_display.cc
@@ -23,6 +23,7 @@
#include "wx_util.h"
#include "lib/timer.h"
#include <dcp/locale_convert.h>
+#include <fmt/format.h>
#include <list>
@@ -47,15 +48,15 @@ TimerDisplay::TimerDisplay (wxWindow* parent, StateTimer const & timer, int gets
});
add(char_to_wx("get() calls"), true);
- add (std_to_wx(dcp::locale_convert<string>(gets)), false);
+ add(std_to_wx(fmt::format("{:L}", gets)), false);
add_spacer ();
add_spacer ();
for (auto const& i: sorted) {
add (std_to_wx(i.first), true);
- add (std_to_wx(dcp::locale_convert<string>(i.second.total_time)), false);
- add (std_to_wx(dcp::locale_convert<string>(i.second.number)), false);
- add (std_to_wx(dcp::locale_convert<string>(i.second.total_time / i.second.number)), false);
+ add(std_to_wx(fmt::format("{:L}", (i.second.total_time))), false);
+ add(std_to_wx(fmt::format("{:L}", (i.second.number))), false);
+ add(std_to_wx(fmt::format("{:L}", (i.second.total_time / i.second.number))), false);
}
layout ();
diff --git a/src/wx/video_waveform_plot.cc b/src/wx/video_waveform_plot.cc
index ebff68096..5b3887e33 100644
--- a/src/wx/video_waveform_plot.cc
+++ b/src/wx/video_waveform_plot.cc
@@ -131,7 +131,7 @@ VideoWaveformPlot::paint ()
} else if (n < 1000) {
x += extra[2];
}
- gc->DrawText (std_to_wx(locale_convert<string>(n)), x, y - (label_height / 2));
+ gc->DrawText(std_to_wx(fmt::format("{:L}", n)), x, y - (label_height / 2));
}
wxImage waveform (_waveform->size().width, height, _waveform->data()[0], true);
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 66ff200cc..213a564c7 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -593,17 +593,17 @@ setup_audio_channels_choice (wxChoice* choice, int minimum)
vector<pair<string, string>> items;
for (int i = minimum; i <= 16; i += 2) {
if (i == 2) {
- items.push_back (make_pair(wx_to_std(_("2 - stereo")), locale_convert<string>(i)));
+ items.push_back(make_pair(wx_to_std(_("2 - stereo")), fmt::to_string(i)));
} else if (i == 4) {
- items.push_back (make_pair(wx_to_std(_("4 - L/C/R/Lfe")), locale_convert<string>(i)));
+ items.push_back(make_pair(wx_to_std(_("4 - L/C/R/Lfe")), fmt::to_string(i)));
} else if (i == 6) {
- items.push_back (make_pair(wx_to_std(_("6 - 5.1")), locale_convert<string>(i)));
+ items.push_back(make_pair(wx_to_std(_("6 - 5.1")), fmt::to_string(i)));
} else if (i == 8) {
- items.push_back (make_pair(wx_to_std(_("8 - 5.1/HI/VI")), locale_convert<string>(i)));
+ items.push_back(make_pair(wx_to_std(_("8 - 5.1/HI/VI")), fmt::to_string(i)));
} else if (i == 12) {
- items.push_back (make_pair(wx_to_std(_("12 - 7.1/HI/VI")), locale_convert<string>(i)));
+ items.push_back(make_pair(wx_to_std(_("12 - 7.1/HI/VI")), fmt::to_string(i)));
} else {
- items.push_back (make_pair(locale_convert<string> (i), locale_convert<string>(i)));
+ items.push_back(make_pair(fmt::to_string(i), fmt::to_string(i)));
}
}