Localization: Localization of units used for time and used filament estimation (part of #10568)
+ Added "ExtrusionRole.cpp" to localization/list.txt to revert localization for the extrusion roles + Updated POT
This commit is contained in:
parent
91dc410f88
commit
3c1008f226
File diff suppressed because it is too large
Load Diff
@ -98,7 +98,7 @@ src/slic3r/Utils/Process.cpp
|
|||||||
src/slic3r/Utils/Repetier.cpp
|
src/slic3r/Utils/Repetier.cpp
|
||||||
src/slic3r/Config/Snapshot.cpp
|
src/slic3r/Config/Snapshot.cpp
|
||||||
src/libslic3r/GCode.cpp
|
src/libslic3r/GCode.cpp
|
||||||
src/libslic3r/ExtrusionEntity.cpp
|
src/libslic3r/ExtrusionRole.cpp
|
||||||
src/libslic3r/Flow.cpp
|
src/libslic3r/Flow.cpp
|
||||||
src/libslic3r/Format/3mf.cpp
|
src/libslic3r/Format/3mf.cpp
|
||||||
src/libslic3r/Format/AMF.cpp
|
src/libslic3r/Format/AMF.cpp
|
||||||
@ -111,6 +111,7 @@ src/libslic3r/SLA/Pad.cpp
|
|||||||
src/libslic3r/SLA/Hollowing.cpp
|
src/libslic3r/SLA/Hollowing.cpp
|
||||||
src/libslic3r/SLAPrint.cpp
|
src/libslic3r/SLAPrint.cpp
|
||||||
src/libslic3r/SLAPrintSteps.cpp
|
src/libslic3r/SLAPrintSteps.cpp
|
||||||
|
src/libslic3r/Utils.cpp
|
||||||
src/libslic3r/PrintBase.cpp
|
src/libslic3r/PrintBase.cpp
|
||||||
src/libslic3r/PrintConfig.cpp
|
src/libslic3r/PrintConfig.cpp
|
||||||
src/libslic3r/Zipper.cpp
|
src/libslic3r/Zipper.cpp
|
||||||
|
@ -307,43 +307,9 @@ public:
|
|||||||
|
|
||||||
// Shorten the dhms time by removing the seconds, rounding the dhm to full minutes
|
// Shorten the dhms time by removing the seconds, rounding the dhm to full minutes
|
||||||
// and removing spaces.
|
// and removing spaces.
|
||||||
inline std::string short_time(const std::string &time)
|
std::string short_time(const std::string& time, bool force_localization = false);
|
||||||
{
|
// localized short_time used on UI
|
||||||
// Parse the dhms time format.
|
inline std::string short_time_ui(const std::string& time) { return short_time(time, true); }
|
||||||
int days = 0;
|
|
||||||
int hours = 0;
|
|
||||||
int minutes = 0;
|
|
||||||
int seconds = 0;
|
|
||||||
if (time.find('d') != std::string::npos)
|
|
||||||
::sscanf(time.c_str(), "%dd %dh %dm %ds", &days, &hours, &minutes, &seconds);
|
|
||||||
else if (time.find('h') != std::string::npos)
|
|
||||||
::sscanf(time.c_str(), "%dh %dm %ds", &hours, &minutes, &seconds);
|
|
||||||
else if (time.find('m') != std::string::npos)
|
|
||||||
::sscanf(time.c_str(), "%dm %ds", &minutes, &seconds);
|
|
||||||
else if (time.find('s') != std::string::npos)
|
|
||||||
::sscanf(time.c_str(), "%ds", &seconds);
|
|
||||||
// Round to full minutes.
|
|
||||||
if (days + hours + minutes > 0 && seconds >= 30) {
|
|
||||||
if (++minutes == 60) {
|
|
||||||
minutes = 0;
|
|
||||||
if (++hours == 24) {
|
|
||||||
hours = 0;
|
|
||||||
++days;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Format the dhm time.
|
|
||||||
char buffer[64];
|
|
||||||
if (days > 0)
|
|
||||||
::sprintf(buffer, "%dd%dh%dm", days, hours, minutes);
|
|
||||||
else if (hours > 0)
|
|
||||||
::sprintf(buffer, "%dh%dm", hours, minutes);
|
|
||||||
else if (minutes > 0)
|
|
||||||
::sprintf(buffer, "%dm", minutes);
|
|
||||||
else
|
|
||||||
::sprintf(buffer, "%ds", seconds);
|
|
||||||
return buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Returns the given time is seconds in format DDd HHh MMm SSs
|
// Returns the given time is seconds in format DDd HHh MMm SSs
|
||||||
inline std::string get_time_dhms(float time_in_secs)
|
inline std::string get_time_dhms(float time_in_secs)
|
||||||
|
@ -983,6 +983,61 @@ std::string xml_escape_double_quotes_attribute_value(std::string text)
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string short_time(const std::string &time, bool force_localization /*= false*/)
|
||||||
|
{
|
||||||
|
// Parse the dhms time format.
|
||||||
|
int days = 0;
|
||||||
|
int hours = 0;
|
||||||
|
int minutes = 0;
|
||||||
|
int seconds = 0;
|
||||||
|
if (time.find('d') != std::string::npos)
|
||||||
|
::sscanf(time.c_str(), "%dd %dh %dm %ds", &days, &hours, &minutes, &seconds);
|
||||||
|
else if (time.find('h') != std::string::npos)
|
||||||
|
::sscanf(time.c_str(), "%dh %dm %ds", &hours, &minutes, &seconds);
|
||||||
|
else if (time.find('m') != std::string::npos)
|
||||||
|
::sscanf(time.c_str(), "%dm %ds", &minutes, &seconds);
|
||||||
|
else if (time.find('s') != std::string::npos)
|
||||||
|
::sscanf(time.c_str(), "%ds", &seconds);
|
||||||
|
// Round to full minutes.
|
||||||
|
if (days + hours + minutes > 0 && seconds >= 30) {
|
||||||
|
if (++minutes == 60) {
|
||||||
|
minutes = 0;
|
||||||
|
if (++hours == 24) {
|
||||||
|
hours = 0;
|
||||||
|
++days;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format the dhm time
|
||||||
|
|
||||||
|
if (force_localization) {
|
||||||
|
auto get_d = [days]() { return format(_u8L("%1%d"), days); };
|
||||||
|
auto get_h = [hours]() { return format(_u8L("%1%h"), hours); };
|
||||||
|
// TRN "m" means "minutes"
|
||||||
|
auto get_m = [minutes]() { return format(_u8L("%1%m"), minutes); };
|
||||||
|
|
||||||
|
if (days > 0)
|
||||||
|
return get_d() + get_h() + get_m();
|
||||||
|
if (hours > 0)
|
||||||
|
return get_h() + get_m();
|
||||||
|
if (minutes > 0)
|
||||||
|
return get_m();
|
||||||
|
return format(_u8L("%1%s"), seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
char buffer[64];
|
||||||
|
if (days > 0)
|
||||||
|
::sprintf(buffer, "%dd%dh%dm", days, hours, minutes);
|
||||||
|
else if (hours > 0)
|
||||||
|
::sprintf(buffer, "%dh%dm", hours, minutes);
|
||||||
|
else if (minutes > 0)
|
||||||
|
::sprintf(buffer, "%dm", minutes);
|
||||||
|
else
|
||||||
|
::sprintf(buffer, "%ds", seconds);
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
std::string format_memsize_MB(size_t n)
|
std::string format_memsize_MB(size_t n)
|
||||||
{
|
{
|
||||||
std::string out;
|
std::string out;
|
||||||
|
@ -708,28 +708,28 @@ static wxString short_and_splitted_time(const std::string& time)
|
|||||||
::sscanf(time.c_str(), "%ds", &seconds);
|
::sscanf(time.c_str(), "%ds", &seconds);
|
||||||
|
|
||||||
// Format the dhm time.
|
// Format the dhm time.
|
||||||
char buffer[64];
|
auto get_d = [days]() { return format(_u8L("%1%d"), days); };
|
||||||
|
auto get_h = [hours]() { return format(_u8L("%1%h"), hours); };
|
||||||
|
auto get_m = [minutes](){ return format(_u8L("%1%m"), minutes); };
|
||||||
|
auto get_s = [seconds](){ return format(_u8L("%1%s"), seconds); };
|
||||||
|
|
||||||
if (days > 0)
|
if (days > 0)
|
||||||
::sprintf(buffer, "%dd%dh\n%dm", days, hours, minutes);
|
return format_wxstr("%1%%2%\n%3%", get_d(), get_h(), get_m());
|
||||||
else if (hours > 0) {
|
if (hours > 0) {
|
||||||
if (hours < 10 && minutes < 10 && seconds < 10)
|
if (hours < 10 && minutes < 10 && seconds < 10)
|
||||||
::sprintf(buffer, "%dh%dm%ds", hours, minutes, seconds);
|
return format_wxstr("%1%%2%%3%", get_h(), get_m(), get_s());
|
||||||
else if (hours > 10 && minutes > 10 && seconds > 10)
|
if (hours > 10 && minutes > 10 && seconds > 10)
|
||||||
::sprintf(buffer, "%dh\n%dm\n%ds", hours, minutes, seconds);
|
return format_wxstr("%1%\n%2%\n%3%", get_h(), get_m(), get_s());
|
||||||
else if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
|
if ((minutes < 10 && seconds > 10) || (minutes > 10 && seconds < 10))
|
||||||
::sprintf(buffer, "%dh\n%dm%ds", hours, minutes, seconds);
|
return format_wxstr("%1%\n%2%%3%", get_h(), get_m(), get_s());
|
||||||
else
|
return format_wxstr("%1%%2%\n%3%", get_h(), get_m(), get_s());
|
||||||
::sprintf(buffer, "%dh%dm\n%ds", hours, minutes, seconds);
|
|
||||||
}
|
}
|
||||||
else if (minutes > 0) {
|
if (minutes > 0) {
|
||||||
if (minutes > 10 && seconds > 10)
|
if (minutes > 10 && seconds > 10)
|
||||||
::sprintf(buffer, "%dm\n%ds", minutes, seconds);
|
return format_wxstr("%1%\n%2%", get_m(), get_s());
|
||||||
else
|
return format_wxstr("%1%%2%", get_m(), get_s());
|
||||||
::sprintf(buffer, "%dm%ds", minutes, seconds);
|
|
||||||
}
|
}
|
||||||
else
|
return from_u8(get_s());
|
||||||
::sprintf(buffer, "%ds", seconds);
|
|
||||||
return wxString::FromUTF8(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const
|
wxString Control::get_label(int tick, LabelType label_type/* = ltHeightWithLayer*/) const
|
||||||
|
@ -3271,6 +3271,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
// draw text
|
// draw text
|
||||||
ImGui::Dummy({ icon_size, icon_size });
|
ImGui::Dummy({ icon_size, icon_size });
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
|
|
||||||
|
// localize "g" and "m" units
|
||||||
|
const std::string& grams = _u8L("g");
|
||||||
|
const std::string& inches = _u8L("in");
|
||||||
|
const std::string& metres = _CTX_utf8(L_CONTEXT("m", "Metre"), "Metre");
|
||||||
if (callback != nullptr) {
|
if (callback != nullptr) {
|
||||||
if (ImGui::MenuItem(label.c_str()))
|
if (ImGui::MenuItem(label.c_str()))
|
||||||
callback();
|
callback();
|
||||||
@ -3306,10 +3311,10 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
::sprintf(buf, "%.1f%%", 100.0f * percent);
|
::sprintf(buf, "%.1f%%", 100.0f * percent);
|
||||||
ImGui::TextUnformatted((percent > 0.0f) ? buf : "");
|
ImGui::TextUnformatted((percent > 0.0f) ? buf : "");
|
||||||
ImGui::SameLine(offsets[2]);
|
ImGui::SameLine(offsets[2]);
|
||||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m);
|
::sprintf(buf, "%.2f %s", used_filament_m, (imperial_units ? inches : metres).c_str());
|
||||||
imgui.text(buf);
|
imgui.text(buf);
|
||||||
ImGui::SameLine(offsets[3]);
|
ImGui::SameLine(offsets[3]);
|
||||||
::sprintf(buf, "%.2f g", used_filament_g);
|
::sprintf(buf, "%.2f %s", used_filament_g, grams.c_str());
|
||||||
imgui.text(buf);
|
imgui.text(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3332,10 +3337,10 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
else if (used_filament_m > 0.0) {
|
else if (used_filament_m > 0.0) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
ImGui::SameLine(offsets[0]);
|
ImGui::SameLine(offsets[0]);
|
||||||
::sprintf(buf, imperial_units ? "%.2f in" : "%.2f m", used_filament_m);
|
::sprintf(buf, "%.2f %s", used_filament_m, (imperial_units ? inches : metres).c_str());
|
||||||
imgui.text(buf);
|
imgui.text(buf);
|
||||||
ImGui::SameLine(offsets[1]);
|
ImGui::SameLine(offsets[1]);
|
||||||
::sprintf(buf, "%.2f g", used_filament_g);
|
::sprintf(buf, "%.2f %s", used_filament_g, grams.c_str());
|
||||||
imgui.text(buf);
|
imgui.text(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3506,7 +3511,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
if (role < GCodeExtrusionRole::Count) {
|
if (role < GCodeExtrusionRole::Count) {
|
||||||
labels.push_back(_u8L(gcode_extrusion_role_to_string(role)));
|
labels.push_back(_u8L(gcode_extrusion_role_to_string(role)));
|
||||||
auto [time, percent] = role_time_and_percent(role);
|
auto [time, percent] = role_time_and_percent(role);
|
||||||
times.push_back((time > 0.0f) ? short_time(get_time_dhms(time)) : "");
|
times.push_back((time > 0.0f) ? short_time_ui(get_time_dhms(time)) : "");
|
||||||
percents.push_back(percent);
|
percents.push_back(percent);
|
||||||
max_time_percent = std::max(max_time_percent, percent);
|
max_time_percent = std::max(max_time_percent, percent);
|
||||||
auto [used_filament_m, used_filament_g] = used_filament_per_role(role);
|
auto [used_filament_m, used_filament_g] = used_filament_per_role(role);
|
||||||
@ -3630,7 +3635,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_buffers[buffer_id(EMoveType::Travel)].visible)
|
if (m_buffers[buffer_id(EMoveType::Travel)].visible)
|
||||||
append_item(EItemType::Line, Travel_Colors[0], _u8L("Travel"), true, short_time(get_time_dhms(time_mode.travel_time)),
|
append_item(EItemType::Line, Travel_Colors[0], _u8L("Travel"), true, short_time_ui(get_time_dhms(time_mode.travel_time)),
|
||||||
time_mode.travel_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
|
time_mode.travel_time / time_mode.time, max_time_percent, offsets, 0.0f, 0.0f);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -3807,7 +3812,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
ImGuiWrapper::to_ImU32(color2));
|
ImGuiWrapper::to_ImU32(color2));
|
||||||
|
|
||||||
ImGui::SameLine(offsets[0]);
|
ImGui::SameLine(offsets[0]);
|
||||||
imgui.text(short_time(get_time_dhms(times.second - times.first)));
|
imgui.text(short_time_ui(get_time_dhms(times.second - times.first)));
|
||||||
};
|
};
|
||||||
|
|
||||||
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||||
@ -3823,9 +3828,9 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
ImGuiWrapper::to_ImU32(color));
|
ImGuiWrapper::to_ImU32(color));
|
||||||
|
|
||||||
ImGui::SameLine(offsets[0]);
|
ImGui::SameLine(offsets[0]);
|
||||||
imgui.text(short_time(get_time_dhms(times.second)));
|
imgui.text(short_time_ui(get_time_dhms(times.second)));
|
||||||
ImGui::SameLine(offsets[1]);
|
ImGui::SameLine(offsets[1]);
|
||||||
imgui.text(short_time(get_time_dhms(times.first)));
|
imgui.text(short_time_ui(get_time_dhms(times.first)));
|
||||||
if (used_filament.first > 0.0f) {
|
if (used_filament.first > 0.0f) {
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
ImGui::SameLine(offsets[2]);
|
ImGui::SameLine(offsets[2]);
|
||||||
@ -3850,7 +3855,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
case PartialTime::EType::Pause: { labels.push_back(_u8L("Pause")); break; }
|
case PartialTime::EType::Pause: { labels.push_back(_u8L("Pause")); break; }
|
||||||
case PartialTime::EType::ColorChange: { labels.push_back(_u8L("Color change")); break; }
|
case PartialTime::EType::ColorChange: { labels.push_back(_u8L("Color change")); break; }
|
||||||
}
|
}
|
||||||
times.push_back(short_time(get_time_dhms(item.times.second)));
|
times.push_back(short_time_ui(get_time_dhms(item.times.second)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3883,7 +3888,7 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
case PartialTime::EType::Pause: {
|
case PartialTime::EType::Pause: {
|
||||||
imgui.text(_u8L("Pause"));
|
imgui.text(_u8L("Pause"));
|
||||||
ImGui::SameLine(offsets[0]);
|
ImGui::SameLine(offsets[0]);
|
||||||
imgui.text(short_time(get_time_dhms(item.times.second - item.times.first)));
|
imgui.text(short_time_ui(get_time_dhms(item.times.second - item.times.first)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PartialTime::EType::ColorChange: {
|
case PartialTime::EType::ColorChange: {
|
||||||
@ -4001,11 +4006,11 @@ void GCodeViewer::render_legend(float& legend_height)
|
|||||||
if (ImGui::BeginTable("Times", 2)) {
|
if (ImGui::BeginTable("Times", 2)) {
|
||||||
if (!time_mode.layers_times.empty()) {
|
if (!time_mode.layers_times.empty()) {
|
||||||
add_strings_row_to_table(_u8L("First layer") + ":", ImGuiWrapper::COL_ORANGE_LIGHT,
|
add_strings_row_to_table(_u8L("First layer") + ":", ImGuiWrapper::COL_ORANGE_LIGHT,
|
||||||
short_time(get_time_dhms(time_mode.layers_times.front())), ImGuiWrapper::to_ImVec4(ColorRGBA::WHITE()));
|
short_time_ui(get_time_dhms(time_mode.layers_times.front())), ImGuiWrapper::to_ImVec4(ColorRGBA::WHITE()));
|
||||||
}
|
}
|
||||||
|
|
||||||
add_strings_row_to_table(_u8L("Total") + ":", ImGuiWrapper::COL_ORANGE_LIGHT,
|
add_strings_row_to_table(_u8L("Total") + ":", ImGuiWrapper::COL_ORANGE_LIGHT,
|
||||||
short_time(get_time_dhms(time_mode.time)), ImGuiWrapper::to_ImVec4(ColorRGBA::WHITE()));
|
short_time_ui(get_time_dhms(time_mode.time)), ImGuiWrapper::to_ImVec4(ColorRGBA::WHITE()));
|
||||||
|
|
||||||
ImGui::EndTable();
|
ImGui::EndTable();
|
||||||
}
|
}
|
||||||
|
@ -1370,7 +1370,7 @@ void Sidebar::update_sliced_info_sizer()
|
|||||||
}
|
}
|
||||||
p->sliced_info->SetTextAndShow(siCost, str_total_cost, "Cost");
|
p->sliced_info->SetTextAndShow(siCost, str_total_cost, "Cost");
|
||||||
|
|
||||||
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : get_time_dhms(float(ps.estimated_print_time));
|
wxString t_est = std::isnan(ps.estimated_print_time) ? "N/A" : from_u8(short_time_ui(get_time_dhms(float(ps.estimated_print_time))));
|
||||||
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _L("Estimated printing time") + ":");
|
p->sliced_info->SetTextAndShow(siEstimatedTime, t_est, _L("Estimated printing time") + ":");
|
||||||
|
|
||||||
p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + boost::nowide::narrow(t_est), p->plater->is_sidebar_collapsed());
|
p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + boost::nowide::narrow(t_est), p->plater->is_sidebar_collapsed());
|
||||||
@ -1459,14 +1459,14 @@ void Sidebar::update_sliced_info_sizer()
|
|||||||
new_label = _L("Estimated printing time") + ":";
|
new_label = _L("Estimated printing time") + ":";
|
||||||
if (ps.estimated_normal_print_time != "N/A") {
|
if (ps.estimated_normal_print_time != "N/A") {
|
||||||
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
new_label += format_wxstr("\n - %1%", _L("normal mode"));
|
||||||
info_text += format_wxstr("\n%1%", short_time(ps.estimated_normal_print_time));
|
info_text += format_wxstr("\n%1%", short_time_ui(ps.estimated_normal_print_time));
|
||||||
|
|
||||||
p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + ps.estimated_normal_print_time, p->plater->is_sidebar_collapsed());
|
p->plater->get_notification_manager()->set_slicing_complete_print_time(_u8L("Estimated printing time") + ": " + ps.estimated_normal_print_time, p->plater->is_sidebar_collapsed());
|
||||||
|
|
||||||
}
|
}
|
||||||
if (ps.estimated_silent_print_time != "N/A") {
|
if (ps.estimated_silent_print_time != "N/A") {
|
||||||
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
new_label += format_wxstr("\n - %1%", _L("stealth mode"));
|
||||||
info_text += format_wxstr("\n%1%", short_time(ps.estimated_silent_print_time));
|
info_text += format_wxstr("\n%1%", short_time_ui(ps.estimated_silent_print_time));
|
||||||
}
|
}
|
||||||
p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label);
|
p->sliced_info->SetTextAndShow(siEstimatedTime, info_text, new_label);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user