diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-26 00:22:12 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-26 00:27:12 +0100 |
| commit | c87429313b25d102201a013e22e01dae8ba78b5b (patch) | |
| tree | f8265c937f8297712f7ab3680f2b0ede81c94ddf /src/lib | |
| parent | 8caf013a9b8d709ed7c3d5e9febee0067e6fcf1f (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.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/content.cc | 4 | ||||
| -rw-r--r-- | src/lib/transcode_job.cc | 4 | ||||
| -rw-r--r-- | src/lib/user_property.h | 11 | ||||
| -rw-r--r-- | src/lib/util.cc | 6 | ||||
| -rw-r--r-- | src/lib/writer.cc | 6 |
5 files changed, 19 insertions, 12 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()); |
